Results 1 to 5 of 5
  1. #1
    bcg9 is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

    Default Invalid operation at current cursor position

    I am trying to pull data from a derby database I have set up. I have included the call below.
    All the variables have been properly initialized. There are numerous calls to the same database before this line of code. All work fine until it hits the print statement.

    The sql call works properly when executed straight on the database. All the fields have non null values.

    stmt = conn.createStatement();
    ResultSet results = stmt.executeQuery("SELECT te.SENDTO, te.REQUESTNUM, ei.SUB, ei.REQTP, ei.CUSTOMER, er.ESCNUM, te.CRITERIA FROM TODAYSESCALATIONS AS te JOIN EINFO AS ei ON te.REQUESTNUM = ei.TRACKNUM JOIN ESCALATIONREQUESTS AS er ON te.REQUESTNUM = er.REQUESTNUM ORDER BY SENDTO, PRIORITY, ESCNUM");
    ResultSetMetaData rsmd = results.getMetaData();

    System.out.println(results.getString("SENDTO"));

    Any suggestions would be appreciated.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    A few possibilities. The ResultSet is empty or SENDTO is not a valid column name.

    Copy and paste the full and exact error message.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    You haven't advanced the resultSet.
    When you execute a query the returned ResultSet is pointing before the first record.
    Attempting to access data at that point results in the error you've just got.
    You need to advance the cursor.
    Java Code:
    if (results.next()) {
        // do stuff with that row
    }
    If you have multiple rows to process then that would be a while loop, not an if statement.

  4. #4
    mntman318 is offline Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Default Re: Invalid operation at current cursor position

    Quote Originally Posted by bcg9 View Post
    I am trying to pull data from a derby database I have set up. I have included the call below.
    All the variables have been properly initialized. There are numerous calls to the same database before this line of code. All work fine until it hits the print statement.

    The sql call works properly when executed straight on the database. All the fields have non null values.

    stmt = conn.createStatement();
    ResultSet results = stmt.executeQuery("SELECT te.SENDTO, te.REQUESTNUM, ei.SUB, ei.REQTP, ei.CUSTOMER, er.ESCNUM, te.CRITERIA FROM TODAYSESCALATIONS AS te JOIN EINFO AS ei ON te.REQUESTNUM = ei.TRACKNUM JOIN ESCALATIONREQUESTS AS er ON te.REQUESTNUM = er.REQUESTNUM ORDER BY SENDTO, PRIORITY, ESCNUM");
    ResultSetMetaData rsmd = results.getMetaData();

    System.out.println(results.getString("SENDTO"));

    Any suggestions would be appreciated.
    "results" is the class with the method getMetaData, the results are in the ResultSetMetaData object "rsmd"
    like mentioned while(rsmd.next());
    //output the string
    rsmd.getString will print a string of the column
    System.out.println(rsmd.getString("<column name>"))

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: Invalid operation at current cursor position

    This is over 18 months old, and the question was answered.
    Locking.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. cursor position in text area
    By Saran185 in forum AWT / Swing
    Replies: 1
    Last Post: 02-02-2011, 07:00 AM
  2. Replies: 4
    Last Post: 06-27-2010, 06:03 PM
  3. change the mouse cursor - crosshair cursor
    By cassysumandak in forum New To Java
    Replies: 1
    Last Post: 09-28-2009, 01:57 AM
  4. Replies: 0
    Last Post: 07-02-2009, 10:42 AM
  5. get position in string from caret position
    By helloworld111 in forum AWT / Swing
    Replies: 5
    Last Post: 02-19-2009, 01:36 AM

Posting Permissions

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