인프런 커뮤니티 질문&답변

다시자바님의 프로필 이미지
다시자바

작성한 질문수

bad SQL grammar [select * from member where name = ?] 왜 에러가 나는지 모르겠네요 문법에 문제가 없는듯한데요;; 파라메터 name 값이 쿼리에 대입이 안되는건지?;;

작성

·

4

·

수정됨

0

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [select * from member where name = ?]

at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:103)

at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:107)

at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1548)

at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:677)

at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:723)

at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:754)

at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:767)

at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:825)

at azul.hello.Repository.JdbcTemplateMemberRepository.findByName(JdbcTemplateMemberRepository.java:44)

at azul.hello.service.MemberService.checkDuplicateName(MemberService.java:37)

at azul.hello.service.MemberService.join(MemberService.java:31)

at azul.hello.service.MemberServiceIntTest.join(MemberServiceIntTest.java:29)

at java.base/java.lang.reflect.Method.invoke(Method.java:569)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

 

=========================================

코드 부분

@Override
public Optional<Member> findByName(String name) {
    List<Member> result = jdbcTemplate.query("select * from member where name = ?", memberRowMapper(), name);
    System.out.println("sql = "+ result.stream().findAny());
    return result.stream().findAny();
}

 

 

 

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
다시자바님의 프로필 이미지
다시자바

작성한 질문수

질문하기