Results 1 to 3 of 3

Thread: Please help

  1. #1
    skiing is offline Member
    Join Date
    Nov 2008
    Posts
    15
    Rep Power
    0

    Default 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);
    }

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    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.

  3. #3
    skiing is offline Member
    Join Date
    Nov 2008
    Posts
    15
    Rep Power
    0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •