Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

an illigal cursor status.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Can anyone give me al clue?
I want to execute a the following query on an MS access DB via jdbc-odbc bridge
Class.forName(DRIVER);
Connection con = DriverManager.getConnection(URL);
Statement st = con.createStatement();
con.setAutoCommit(true);
ResultSet rs = st.executeQuery("SELECT MAX(persId) FROM Persoon");
System.out.println(rs.getInt("persId"));

I would like it to return the max value of the int persId.
But i get an 'Illigal cursor status' (SQLException id=43).
I'm working with tomcat 5.0 and eclipse.

I hope someone knows what i'm doing..............wrong.

thanks

Levien.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Levien de Reu!

I'm moving this to the JDBC forum...
 
author & internet detective
Posts: 39755
797
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Levien,
Since you are using an aggregate function (max), the column name is not defined. You have two choices:

1) Use a column number:

2) Give the column a name:


Also make sure you are calling rs.next() before accessing the column. Otherwise, the cursor is pointing to a position before that of the result.
 
Levien de Reu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne,

Many Thanx, it works !
Except the get method, i used a getInt.
But i assume that was what you ment.




bye
 
Jeanne Boyarsky
author & internet detective
Posts: 39755
797
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I meant getInt(). Glad to hear you have it working.
 
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!