Estoy haciendo una ejecución de consulta simple preparedstatement y me lanza este error: java.sql.SQLException: El uso del método executeQuery (cadena) no se admite en este tipo de instrucción en net.sourceforge.jtds.jdbc. JtdsPreparedStatement.notSupported (JtdsPreparedStatement.java:197) en net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery (JtdsPreparedStatement.java:822) en testconn.itemcheck (testconn.java:58)java: uso de método executeQuery (cadena) ¿error no soportado?
¿Alguna idea de lo que estoy haciendo incorrectamente? gracias de antemano aquí está el código:
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
Por segundo punto ... Incluso me hicieron el mismo error. Gracias, ahorraste mucho tiempo –