java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state

Joined
Aug 28, 2009
Messages
1
Reaction score
0
I am getting an exception (java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state)
while running this program given below. Please help.


import java.sql.*;
import java.io.*;

class Dbconnect1
{
public static void main(String[] args)
{
String str[]={"Yahoo","Yah"};
int count=0;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:eek:dbc:db");

String query="Select distinct id from employee";
Statement st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs = st.executeQuery(query);

rs.beforeFirst();
while(rs.next())
{
System.out.println(rs.getInt(1));
}
st.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
i am getting the exception at line:

System.out.println(rs.getInt(1));

output is
1
2
3
4
5
6
7
8
9
10
11
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)
at Dbconnect1.main(Dbconnect1.java:29)
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top