데이터베이스 값을 텍스트 필드 값과 비교하는 간단한 응용 프로그램을 만들었지 만 프로젝트를 실행할 때 Exception
:java.sql.SQLException : [Microsoft] [ODBC Driver Manager] 커서 상태가 올바르지 않음
java.sql.SQLException
:,691 : [마이크로 소프트] [ODBC 드라이버 관리자] 잘못된 커서 상태private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { String dataSource ="testDb"; String U="jdbc:odbc:"+dataSource; try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection(U,"",""); PreparedStatement s=con.prepareStatement("Select * from student"); ResultSet s1=s.executeQuery(); String textField; textField=jTextField1.getText(); String database =s1.getString(1); if(textField.equals(database)) { System.out.println("ok"); } else { System.out.println("Not ok"); } } catch(Exception ex) { System.out.println("THE EXCEPTION IS"+ex); } }
이것은 내가 사용하는 코드입니다
이 경우 Exception
이 원인 일 수 있습니까? 당신이 s.executeQuery()
을 수행 할 때
감사합니다. 작동하지 않습니다. – king
예외없이 작동 했습니까? –