Wykonuję proste wykonanie kwerendy przygotowań i rzuca mi ten błąd: java.sql.SQLException: Użycie metody executeQuery (string) nie jest obsługiwane dla tego typu instrukcji w net.sourceforge.jtds.jdbc. JtdsPreparedStatement.notSupported (JtdsPreparedStatement.java:197) w net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery (JtdsPreparedStatement.java:822) w testconn.itemcheck (testconn.java:58)java: użycie metody executeQuery (string) nie jest obsługiwane?
pomysłów, co mam robi nieprawidłowo? z góry dzięki Oto kod:
private static int itemcheck (String itemid) {
String query;
int count = 0;
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
con = java.sql.DriverManager.getConnection(getConnectionUrl2());
con.setAutoCommit(false);
query = "select count(*) as itemcount from timitem where itemid like ?";
//PreparedStatement pstmt = con.prepareStatement(query);
//pstmt.executeUpdate();
PreparedStatement pstmt = con.prepareStatement(query);
pstmt.setString(1,itemid);
java.sql.ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
count = rs.getInt(1);
System.out.println(count);
} //end while
}catch(Exception e){ e.printStackTrace(); }
return (count);
} //end itemcheck
Na drugim miejscu ... nawet zrobiłem ten sam błąd. Dzięki, że zaoszczędziłeś dużo mojego czasu –