• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

java.sql.SQLException: Connection handle has been closed and is unusable

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi iam using jboss 3.2.3 it is giving sqlexception as "java.sql.SQLException: Connection handle has been closed and is unusable" .what may be the problem pls notify me
 
author
Posts: 4278
34
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tempted to move this to the JBoss forum (you might find more help there) but it is probably a JDBC issue.

Are you using connection pooling or direct JDBC? The error your describing is if the database connection has been closed. I'm not sure why you are trying to read a closed database connection instead of opening a new one, but we'd likely need to see some code or hear more information to help.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rai talari:
hi iam using jboss 3.2.3 it is giving sqlexception as "java.sql.SQLException: Connection handle has been closed and is unusable" .what may be the problem pls notify me



rai,

there's a setting in the yourapp-ds.xml file that allows for a reconnection to the database. i think this error is encountered when a network connection from the app server to the db server breaks, or, when the db server is restarted and the app server isn't.

have a look:


taken from a jboss4.0.2serverinstalldir/docs/examples/jca/mysql-ds.xml

hope it helps
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This can be due to the way you handle the transactions. If you try to handle transactions manually with setAutoCommit() and at the same time try to use session beans which in turn do some
database operations using the datasource or entity beans or any other way this can happen.

Solution is to use JTA transactions for your manual transaction part. Following code snippet explains how.


UserTransaction ut = (UserTransaction) c.lookup("java:comp/UserTransaction");


try {
ut.begin();

//insert your database manipulation code here.
//insert your session beans access code here.

ut.commit();
} catch (Throwable ex) {
try {
ut.rollback();
} catch (SystemException syex) {
throw new Exception( "Rollback failed: " + syex.getMessage());
}
throw new Exception( "Transaction failed: " + ex.getMessage());
}

You can refer to my blog for more information.

http://kishantha.blogspot.com/2009/06/mixing-transactions-manual-and.html
 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Kishantha..

How to mixing JTA with Hibernate Template (session) ?.. is it possible?..
May you give me an example?..
i want to make a transaction like this.. (Quoted from your post before)



Do i have to use sessionFactory?

Thanks in advance sir..
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic