• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLEXCEPTION: Already Closed

 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am going to move this to the JDBC forum. This forum is for ORM products like TopLink and Hibernate.

Mark
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the Connection has already been closed, then that closure would also have closed the Statement.
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Patricia,

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

Thanks a lot!
 
Scott Selikoff
author
Saloon Keeper
Posts: 4014
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Patricia Samuel
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic