• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Help with this error PLEASE!!!!!

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am just learning jdbs and i created a test db in access and below is the error that i get
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
this is the code that creates the error
try
{
String strNumber = "124";
Statement cmdEmployees = conEmployees.createStatement();
ResultSet rsEmployees =
cmdEmployees.executeQuery("Select * from employees where ssn= '"+strNumber+"';");

lblOutput.setText(rsEmployees.getString("firstName"));

conEmployees.close();
}
catch(SQLException sqlError)
{
System.out.println("sqlException Error::: ");
System.out.println(sqlError + "\n");


}
i cannot figer out what is going on with this also the program is not loading the microsoft driver it loads the sun driver WHY? this is a Accss XP database here is the code below for that

try
{
Class.forName("com.ms.jdbc.odbc.Jdbc0dbcDriver");

}
catch(ClassNotFoundException error)
{

System.out.println("Could not load Microsoft driver::: " + error + "\n");

try
{
//load sun drivers
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("\n Loaded sun driver::: \n");
}
catch(ClassNotFoundException err)
{
System.out.println("Sun Driver did not load properly" + err + "\n");


}


}
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Invalid cursor state is caused by the fact that when your resultset is created you are positioned before the first row. You have to do yourResultSet.next() to move to the first row. if you plan on processing all rows in the resultset, use a while loop as in
while(yourResultSet.next(){
do whatever...
}
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic