java - ResultSet.next() Throwing SQLException: Result Set Closed -


i've tried debug code , read oracle doc , don't see reason why result set closed.

 statement statement = databaseconnector.connect();     string sql = "select * room room_type '*"+roomtype+"*' "+availability;     boolean foundresults = statement.execute(sql);     if(foundresults){     resultset rs = statement.getresultset();     stringbuilder row = new stringbuilder();     if(rs!=null){     while(rs.next()){ 

re: sqlexception

i'm not quite sure databaseconnector supposed in question code, following test code works me.

re: wildcard character

when using operator in query from within access application itself asterisk * wildcard character use. when querying ace (access) database from other application 1 needs use "standard" percent % wildcard character. note following code uses %; using * won't work here.

import java.sql.*;  public class jdbcquery {     public static void main( string args[] )     {         try         {             class.forname("sun.jdbc.odbc.jdbcodbcdriver");             connection conn = drivermanager.getconnection(                     "jdbc:odbc:driver={microsoft access driver (*.mdb, *.accdb)};" +                      "dbq=c:\\users\\public\\database1.accdb;");             string roomtypetomatch = "suite";             preparedstatement s = conn.preparestatement(                     "select room_no, room_type " +                     "from room room_type ?"                     );             s.setstring(1, "%" + roomtypetomatch + "%");             s.execute();             resultset rs = s.getresultset();             if (rs!=null)             {                 while (rs.next())                 {                     system.out.println("[room_no]: " + rs.getstring(1) +                             ", [room_type]: " + rs.getstring(2));                 }             }             s.close();             conn.close();         }         catch( exception e ) {             e.printstacktrace();         }     } } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -