• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC Connection gets closed just after it is created.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My application is using following way to create a statement through a connection.
1: Connection conn = null;
2: try {
3: conn = ServerUtil.getConnection();
4: ps = conn.prepareStatement(sql.toString());
5: :
6: :
7: } catch {
8: }
9: finally {
10: ServerUtil.releaseConnection();
11: }

ServerUtil is a utility class which provides method to get instance of connection and closing the connection.
But sometimes the application throws SQLException at line number 4 saying that connection is already closed.

The application is deployed in JBoss server and the ServerUtil class is getting connection from some connection pool.

Please reply back in case you need more information.
Waiting for reply.

With Regards
Pranesh Yelkur
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pranesh,


ServerUtil class is getting connection from some connection pool.



We cant guess whats your ServerUtil class does. Post the class.



I suspect the connection (conn) returned from getConnection() does not have proper mechanism to handle when connection object is closed. It should check for something like this and this might be missing in your ServerUtil class

 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree, it sounds like ServerUtil is the problem. In normal JDBC code, once you get a connection it shouldn't be immediately closed on the next line.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic