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