Hi Adam,
        From what I understood u have to do libCount.next() before u can retrieve 
values coz the
cursor is initially positioned just above the first row of a ResultSet object, the 
first call to
the method next moves the cursor to the first row and makes it the current row.
Now do u understand why u r getting the invalid cursor state error?
For more info read Retrieving Values from Result Sets Chapter of JDBC Basics in the 
Java tutorial.

Adam Smith wrote:

> I am using microsoft access (I thought for convenient testing) as the back
> end of a servlet. No matter what I try, I keep getting an "invalid cursor
> state" error with even the simplest query.
>
> I have a system data source set up and I am able to connect fine. Here is
> the code I am using:
>
>                 Statement libraryStatement = 
>libraryConnection.makeProgramConnection();
>
>                 // get count of records in database
>                 int recordCount=0;
>                 String libraryQuery = "SELECT count(*) FROM caLibraries";
>
>                 try {
>
>                         ResultSet libCount = libraryStatement.executeQuery("SELECT 
>count (*)
> FROM caLibraries");
>                         recordCount = libCount.getInt(1);
>                         libraryConnection.closeConnection();
>
>                 } catch (SQLException sqlexception) {
>                         for(; sqlexception != null; sqlexception =
> sqlexception.getNextException()) {
>                                 System.out.println("SQLState :" + 
>sqlexception.getSQLState());
>                                 System.out.println("Message: " + 
>sqlexception.getMessage());
>                                 System.out.println("Vendor: " + 
>sqlexception.getErrorCode());}
>                         }
>
>                 return recordCount;
>
> I can't find any documentation explaining what this error means. Any help
> is appreciated.
>
> ____________________________________
> Adam Smith
> [EMAIL PROTECTED]
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to