-
Please help
I am stuck I am getting an error I don't know what it is coming from the message says invalid cursor state, when comment this out It works just fine, what I am trying to do is have a class have to calls to two differn't databases. Here is my code
try
{
System.out.println("geat");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// set this to a MS Access DB you have on your machine
String filename = "C:/Temp/Test.mdb";
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
// now we can get the connection from the DriverManager
Connection con = DriverManager.getConnection( database ,"","");
System.out.println("test");
Statement s = con.createStatement();
// s.execute(statement1);
s.execute(statement1);
ResultSet rs = s.getResultSet();
if(rs == null){
System.out.println("after results");}
//String bal = rs.getString();
else{
System.out.println("after results55555");}
String Data_Entered = rs.getString(1);
System.out.println("Before");
System.out.println(Data_Entered);
System.out.println("After");
s.close();
con.close();//retrieve data from table
}
catch (Exception FF)
{
System.out.println("Error: " + FF);
}
-
I believe that no row is selected by default in a result set, so you have to call next() or any other method before trying to operate on the row.
-
Thanks
that was it, very simple fix!!!