我的数据库上有一个表,我称之为发件人表,当我想打印字段的内容时,它给了我这个错误
java-sql-sqlexception [microsoft][odbc-driver-manager] invalid cursor state
无论如何这是我的代码
str = "SELECT * FROM Sender WHERE sender_PID= " + sender_PID + "";
try {
rs = stmt.executeQuery (str);
System.out.println (rs.getInt ("sender_PID"));
} catch (Exception ex) {ex.printStackTrace ( );}
我真的很抱歉我的英语不好
database ( )
{
try {
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection ("jdbc:odbc:DB");
stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
} catch (Exception ex) {ex.printStackTrace();}
}
String checkSender (int sender_PID)
{
str = "SELECT sender_PID FROM Sender WHERE sender_PID= " + sender_PID + "";
try {
rs = stmt.executeQuery (str);
while(rs.next())
{
System.out.println (rs.getInt ("sender_PID"));
}
} catch (Exception ex) {ex.printStackTrace ( );}
return "1";
}