*
The moose likes JDBC and the fly likes SQLEXCEPTION: Already Closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLEXCEPTION: Already Closed" Watch "SQLEXCEPTION: Already Closed" New topic
Author

SQLEXCEPTION: Already Closed

Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
Hi all,

Earlier i was using jvm parameters for data base connection URL, user, password. But now, i started using jboss datasource defined in jboss/default/deploy as an xml qds.xml




I am using c3po for connection pooling. When i run my application , i get following exception :
java.sql.SQLException: Already closed
at org.jboss.resource.adapter.jdbc.WrappedStatement.close(WrappedStatement.java:69)

This error is generally thrown in finally block where i am closing pstmt.close();

Interestingly, pstmt.closed is false before committing the transaction but when it invokes pstmt.close(), it finds pstmt already closed( closed=true) and throws the above execption.

It used to work fine till we started using jboss data source.

Can anyone help???
Regards
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I am going to move this to the JDBC forum. This forum is for ORM products like TopLink and Hibernate.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
If the Connection has already been closed, then that closure would also have closed the Statement.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
No, connection has not been already closed. problem is with pstmt.close()
which says close() won't throw an exception if it is already closed. but it does ...

i am using jboss -4.0.4GA , i read some where if i enable aop (Aspector) it can solve my problem

but i dont know how to implement this.

Please suggest me solution for this problem

Thanks
Pedro Gontijo
Greenhorn

Joined: Sep 10, 2008
Posts: 1
Hi Patricia,

Did you find out what was the problem?
I am having the same problem here...

Thanks a lot!
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3703
    
    5

I love problems like these because the exception in this case is extremely helpful. If you're getting a message that a statement is closed, then it is closed. You're task is to figure out why.

Try posting your entire JDBC code snippet (minus the queries) and/or consider in what cases other processes might be closing your objects. 9 times out of 10, connection closed can be traced to a coding error.

Ack, just realized this thread is probably dead since Patricia posted it 9 months ago... For Pedro: my comments still apply.
[ September 10, 2008: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
Patricia Samuel
Ranch Hand

Joined: Sep 12, 2007
Posts: 300
Hi Pedro,

Can you tell me the exact scenario? Are you getting this error from the initial stage or you've started to get this error when you switched to use JNDI.And kindly paste the code for better clarity.

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLEXCEPTION: Already Closed
 
Similar Threads
Oracle Datasource for jboss
ClassCastException Jboss5.0
Datasource without pooling
Problem with JBoss 4.0.3
question about jndi name format