반응형
{"error":1,"message":"qQLExceptionjava.sql.SQLSyntaxErrorException: Unknown column '1' in 'where clause'"}


SQL 구문에 오류가 있다는 뜻


사례) 


ResultSet resultSet = statement.executeQuery("SELECT * FROM goods WHERE id = `" + goodsid +"`"); 


에서 ' 를 `로 잘못 쓴 경우


ResultSet resultSet = statement.executeQuery("SELECT * FROM goods WHERE id = '" + goodsid +"'"); 


로 변경 시, 정상 작동함




cf.  SQL 구문에서는 ' 를 쓰고

     prepareStatement 에서는 ` 를 쓴다.


예시)  pstmt = connection.prepareStatement("INSERT INTO `test`.`Goods` "

                 + "(`title`, `address`, `area`, `deposit`, `month`, `floor`, `maintain`, `type`, `type2`, `elevator`, `parking`, `image_id`) "

                 + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");

   

'개발 > Database' 카테고리의 다른 글

[SQL/오라클] 순번 채번 CONNECT BY LEVEL  (0) 2022.12.08

+ Recent posts