Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.sql.SQLException: Invalid operation at current cursor position.

807601Apr 10 2008 — edited Apr 10 2008
In this code
    System.out.println("patron id = " + patron.getPatronID() + " pin = " + patron.getPin());
                    try {
                        rs = stmnt.executeQuery("SELECT PATRONID, PIN, ENABLED, LAST_LOGIN, END_TIME from PATRONS WHERE PATRONID = " + patron.getPatronID() + " AND PIN =  " + patron.getPin());
                        ResultSetMetaData metaData = rs.getMetaData();
                        int columns=metaData.getColumnCount();
                        boolean noPword = false;
                       
                        if(columns>0){
                        try{
                            long id = rs.getLong(1);
                            int pin = rs.getInt(2);
                            int enabled = rs.getInt(3);
                            last_login = rs.getTimestamp(4);
                            endtime = rs.getTimestamp(5);
                            
                        }catch(SQLException e){
                            noPword = true;
                            System.out.println("sqlexception----- " + e);
                            e.printStackTrace();
                            patron.setAction("login");
                            patron.setErrorMsg("Issue with connecting to the database, please contact staff");
                            patron.setResult(false);
                            sendPatron();
                        }
I'm receiving this error and I'm unsure why

sqlexception----- java.sql.SQLException: Invalid operation at current cursor position.
java.sql.SQLException: Invalid operation at current cursor position.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
at org.apache.derby.client.am.ResultSet.getLong(Unknown Source)
at DBServer.conversation.run(conversation.java:205)
objOut in transmit = java.io.ObjectOutputStream@17f1ba3
at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.derby.client.am.SqlException: Invalid operation at current cursor position.
at org.apache.derby.client.am.ResultSet.checkForValidCursorPosition(Unknown Source)
at org.apache.derby.client.am.ResultSet.checkGetterPreconditions(Unknown Source)
... 3 more

My table structure is as so

PATRONID bigint
PIN bigint
MONEY double
ENABLED numeric 2
LAST_LOGIN timestamp
ENDTIME timestamp
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 8 2008
Added on Apr 10 2008
2 comments
5,076 views