Discussions

General J2EE: Oracle JDBC - Exhausted ResultSet - Help!!!

  1. Oracle JDBC - Exhausted ResultSet - Help!!! (2 messages)

    All,

    After looking at many other Exhausted result set posts and performing a large amount of googling, i have still not managed to solve my SQL exception!!

    the following code:

    ResultSet resultSet = stmt.executeQuery( sql );

    TableField[] metadataFields = params.getBasicQueryMetadata().getBasicQueryFields();

    while ( resultSet.next() );
    {

    for ( int i = 0 ; i < metadataFields.length ; i++ )
    {

    String name = metadataFields.getName();

    String alias = metadataFields.getAlias();

    String value = resultSet.getString( name );

    }
    }

    stmt.close();


    using the oracle thin driver... (url = jdbc:oracle:thin:user/password@host:port:database)

    Always barfs at the line: String value = resultSet.getString( name ); on the first iteration!

    I am not closing the statement/connection/resultset before i run this line of code. I can gurantee that the SQL passed through should generate a resultSet with 25 rows in it (i print out the SQL in a log and copy this into Toad to test it!)

    I am however sharing the Connection object used to create the Statement, but i am currently running the code without any other queries being run, so it cant be that!?

    I have tested that a count(*) query works using the same driver/url and exactly the same SQL - this returns a valid resultset from which i can return how many records should be in the above result set.

    Any other ideas??

    Help!!

    Will
  2. This is not an answer to your problem but a suggestion.

    Consider switching to hibernate.
  3. School boy error[ Go to top ]

    someone on the sun forums spotted it!

    comomoin school boy while loop error

    while (resultSet.Next);
    {
       //code
    }

    notice the ; after the while() declaration????

    stupid me....

    Indeed hibernate might be the way forward in the future!!!

    cheers

    w.