2
여기
내 코드입니다 :의 PreparedStatement SQL 오류
public int checklogin(String email, String key){
int res = -1;
try
{
String selectSQL = "SELECT id FROM table WHERE email = ? AND key = ?";
PreparedStatement preparedStatement = dbConnection.prepareStatement(selectSQL);
preparedStatement.setString(1, email);
preparedStatement.setString(2, key);
ResultSet rs = preparedStatement.executeQuery();
if (rs.next())
res = rs.getInt("id");
rs.close();
preparedStatement.close();
} catch (Exception e) { e.printStackTrace(); }
return res;
}
하지만 난이 얻을 :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key = 'AAA'' at line 1
어디에 문제가?
괜찮아요. 쿼리 브라우저에서 SQL 문을 단독으로 실행 해보십시오. 그게 효과가 있니? –
덧붙여 말하자면, finally 블록에서 close() 문을 실행해야합니다. 문제가되지는 않습니다. –
전달할 전자 메일 및 키의 값은 무엇입니까? 예, 문자열이지만 인코딩에 문제를 일으키는 특수 문자가 있습니까? 팀 B가 말한 것처럼 - 괜찮아 보인다! –