简体   繁体   中英

got error:PreparedStatement… while running java program

i got error while running the java program my code is:

for(int k=0;k<ikm;k++)
 {
 if(word[jm].contains(item1))
  {
  final String query1="SELECT COUNT(*) FROM c_ngram WHERE Words = item1";
  final PreparedStatement ps = conn.prepareStatement(query1);
  ps.setString(1, item1);
  final ResultSet resultSet = ps.executeQuery();
  if(resultSet.next()) {
  final int count = resultSet.getInt(1);

....

error shows in "final PreparedStatement ps" line

please help me

您的查询是错误的,您可能是说:

"SELECT COUNT(*) FROM c_ngram WHERE Words = ?"

Use ? in query string to set parameter

final String query1="SELECT COUNT(*) FROM c_ngram WHERE Words = ?";

To get details about the error you can use try catch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM