| | |
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
Views: 1688 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
android api apple applet application arguments array arrays automation binary bluetooth c# capture chat chatprogramusingobjects class classes client code color component count database design draw eclipse eclipsedevelopment encryption error event exception file fractal game givemetehcodez graphics gridlayout gui helpwithhomework high html ide if_statement image input integer interface j2me java javadesktopapplications javaprojects jmf jni jpanel julia keyword linux list loop macintosh map method methods mobile netbeans newbie number object oracle os print problem producer program programming project projectideas read recursion replaysolutions scanner screen server set size sms socket sort sql string swing test threads time transfer transforms tree ui unicode windows






