I was facing an error in storing the row count obtained from sql into a variable i displayed the one file running code below along with output. i was wondering if you guys could help me with this error. I want to count the no of customers and then append it to a string and generate the customer id.
I want to get he count of customers from a table in oracle 11g db and store it in a variable. I am unable to do so. Please can anyone help me? I have shown the snippet of the code i am trying to write...
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source)
Before you can access the columns from a row of the ResultSet, you have to call "rs.next()" to move to that row. Since your query is guaranteed to return exactly one row, just call rs.next() before you try to get data from the ResultSet and leave it at that. Normally you use rs.next() to control a loop (you've seen the JDBC tutorials, right?) but in this case a loop isn't necessary.