This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes ResultSet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ResultSet" Watch "ResultSet" New topic
Author

ResultSet

duhit Choudhary
Ranch Hand

Joined: Apr 01, 2012
Posts: 64
Hello all,

When I tried to execute this code:



I am getting the Following exception...

java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:803)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:851)
at com.mysql.jdbc.ResultSetImpl.getObject(ResultSetImpl.java:4881)
at bot.MessageUser.cleanUserDetails(MessageUser.java:110)
at bot.JavaBotMainForm.actionPerformed(JavaBotMainForm.java:433)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:682)
at java.awt.EventQueue$3.run(EventQueue.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:696)
at java.awt.EventQueue$4.run(EventQueue.java:694)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)



Please help where I am doing wrong. though the output is self explaining but i am still not able to get why i am getting this...

Thanks in Advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
You can only have a single open ResultSet per Statement at any given time. Obtaining another ResultSet will lead to the previously obtained ResultSet being closed. So this code has problems in lines 8, 13 and 18.


Ping & DNS - my free Android networking tools app
duhit Choudhary
Ranch Hand

Joined: Apr 01, 2012
Posts: 64
Ulf Dittmer wrote:You can only have a single open ResultSet per Statement at any given time. Obtaining another ResultSet will lead to the previously obtained ResultSet being closed. So this code has problems in lines 8, 13 and 18.


thanks.. i knew this.. can you tell me how to resolve this because i am not getting it at all...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41042
    
  43
You need to refactor your code and data structures so that no more than a single ResultSet per Statement is open at any time.

It could be that all you need to do is to switch lines 7 and 8, lines 12 and 13, and lines 17 and 18.
duhit Choudhary
Ranch Hand

Joined: Apr 01, 2012
Posts: 64
Ulf Dittmer wrote:
It could be that all you need to do is to switch lines 7 and 8, lines 12 and 13, and lines 17 and 18.


I have done that but still getting same exception..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ResultSet
 
Similar Threads
NullPointerException thrown by method drawImage()
Getting 'null' value in response to statement.executeUpdate method
Problem reading database.
Please help with NullPointerException
addin two matrices.no display in final cell in the result table:java.lang.NullPointerException error