This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes JBoss/WildFly and the fly likes DataSource.getConnection() returning closed connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "DataSource.getConnection() returning closed connections" Watch "DataSource.getConnection() returning closed connections" New topic

DataSource.getConnection() returning closed connections

Rocker Jagtap

Joined: Aug 04, 2008
Posts: 2
I am having an application which is running on Jboss and Oracle database. I get closed connections while doing Datasource.getConnection(). here is the code

Can some one please let me know, why datasource is returning closed connections

Abid Rafique

Joined: Jan 09, 2012
Posts: 10

can you show us the implementation of ?
that should give us some idea.
Rocker Jagtap

Joined: Aug 04, 2008
Posts: 2
thanks for the reply, here is code behind datasource.getConnection();
Gurumeet Singh Ahuja

Joined: Mar 02, 2012
Posts: 4

Is this the complete snippet for the method.. as i see szDataSource is always null.... and even if its set in the class level [not visible in this snippet] its re-assigned as null again.

String szDataSource = null;
if (datasource == null) {
try {
htParms = new Hashtable();
htParms.put(Context.PROVIDER_URL, szProviderURL);
htParms.put(Context.INITIAL_CONTEXT_FACTORY, szContextFactory);
context = new InitialContext(htParms);
temp = context.lookup(szDataSource);
datasource = (DataSource) temp;
context = null;


With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: DataSource.getConnection() returning closed connections
It's not a secret anymore!