Connection con = null;
Statement sql;
ResultSet rs;
String mm = null;
mm = jTextField1.getText();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("Jdbc:Odbc:order_sell");
sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
if ((Demand_ComboBox.getSelectedItem()).equals("按名称查找")){
rs = sql.executeQuery("select * from Customer where CustomerName LIKE '%" + mm + "%'");
int pass = rs.getInt("Password");
int useid = rs.getInt("CustomerID");
int passtext =Integer.parseInt(new String(Demand_Password.getPassword()));
if(passtext==pass){
Return_Text.setText("useid");
}
else{
System.out.println(444);
Return_Text.setText("输入内容有错");
}
}else{
rs = sql.executeQuery("select * from Customer where Address LIKE '%" + mm + "%'");
int pass = rs.getInt("Password");
String useid = rs.getString("Address");
int passtext =Integer.parseInt(new String(Demand_Password.getPassword())) ;
if(passtext==pass){
Return_Text.setText("useid");
}
else{
Return_Text.setText("输入内容有错");
}
}
} catch (ClassNotFoundException ex) {
System.out.println(111);
} catch (SQLException ex) {
System.out.println(ex);
} }
提示一个异常java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
我机器是win2003
Statement sql;
ResultSet rs;
String mm = null;
mm = jTextField1.getText();
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("Jdbc:Odbc:order_sell");
sql = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
if ((Demand_ComboBox.getSelectedItem()).equals("按名称查找")){
rs = sql.executeQuery("select * from Customer where CustomerName LIKE '%" + mm + "%'");
int pass = rs.getInt("Password");
int useid = rs.getInt("CustomerID");
int passtext =Integer.parseInt(new String(Demand_Password.getPassword()));
if(passtext==pass){
Return_Text.setText("useid");
}
else{
System.out.println(444);
Return_Text.setText("输入内容有错");
}
}else{
rs = sql.executeQuery("select * from Customer where Address LIKE '%" + mm + "%'");
int pass = rs.getInt("Password");
String useid = rs.getString("Address");
int passtext =Integer.parseInt(new String(Demand_Password.getPassword())) ;
if(passtext==pass){
Return_Text.setText("useid");
}
else{
Return_Text.setText("输入内容有错");
}
}
} catch (ClassNotFoundException ex) {
System.out.println(111);
} catch (SQLException ex) {
System.out.println(ex);
} }
提示一个异常java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 无效的游标状态
我机器是win2003
它就还没有指向第一条数据
rs = sql.executeQuery("select * from Customer where CustomerName LIKE '%" + mm + "%'");
// 添加 ..
while(rs.next()){
int pass = rs.getInt("Password");
int useid = rs.getInt("CustomerID");
int passtext =Integer.parseInt(new String(Demand_Password.getPassword()));
if(passtext==pass){
Return_Text.setText("useid");
}
else{
System.out.println(444);
Return_Text.setText("输入内容有错");
}
}