| | |
SQL-JAVA ResultSet problem
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hi,
I get the following exception when i try to run the following code segment.
And the exception i get is:
I get the following exception when i try to run the following code segment.
JAVA Syntax (Toggle Plain Text)
stmt = (Statement) conn.createStatement(); rs = stmt.executeQuery( "SHOW TABLES"); if(rs.first()) { stmt.execute( "DROP TABLE " + rs.getString(1)); while (rs.next()){ stmt.execute( "DROP TABLE " + rs.getString(1)); } }
And the exception i get is:
SQLException: Operation not allowed after ResultSet closed
SQLState: S1000
VendorError: 0
Last edited by yassar; Apr 23rd, 2008 at 4:45 am.
You have executed a new query here through your statement so the result set you obtained with that statement is no longer valid and you cannot retrieve field values from it. Create a separate statement object to make your "DROP TABLE" calls with.
java Syntax (Toggle Plain Text)
stmt.execute( "DROP TABLE " + rs.getString(1));
java Syntax (Toggle Plain Text)
PreparedStatement updateStmt = conn.prepareStatement("DROP TABLE ?"); stmt = conn.createStatement(); rs = stmt.executeQuery( "SHOW TABLES"); while (rs.next()) { updateStmt.setString(1, rs.getString(1)); updateStmt.executeUpdate(); } updateStmt.close(); stmt.close();
![]() |
Similar Threads
- Problem with database connection (JSP)
- JNDI/JDBC lookup problem with Sun Java Application Server 8.2 (Java)
- plz tell me how to solve problem (JSP)
- Problem adding registration data to mysql database (JSP)
- Date type problem JSP, mySQL (Java)
- JSP Problem Student database search (Java)
- Problem connecting my Tomcat Server and MySQL using JSP (JSP)
- Javascript array from sql query (JSP)
- Java JDBC ResultSet (Java)
Other Threads in the Java Forum
- Previous Thread: null pointer exception --- urgent
- Next Thread: Help In Java
| Thread Tools | Search this Thread |
Tag cloud for Java
affinetransform android api append apple applet application arguments array arrays automation bi binary bluetooth businessintelligence busy_handler(null) chat class classes client code component database draw eclipse encryption equation error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer intersect j2me java javaexcel javaprojects jmf jni jpanel julia linked linux list loop main map method methods mobile netbeans newbie number open-source oracle oriented panel print problem program programming project qt recursion reference replaysolutions repositories return robot scanner screen scrollbar se server set singleton size sms socket sort sql string swing test threads time tree utility windows xor






