No ManagedConnections available
deepaksharma Feb 24, 2004 5:05 AMHi All,
I am using Jboss 3.2 and database as oracle 9i. I am using connection pooling and have configured the oracle-ds.xml file. After using the connection i am calling the removeConnection() method of my own Database Connection class so that the connection go back to the pool. my oracle-ds.xml file has following entries:
<min-pool-size>10</min-pool-size>
<max-pool-size>30</max-pool-size>
<blocking-timeout-millis >300000</blocking-timeout-millis >
but after inserting 30 records i am geeting an exception:
- nested throwable: (javax.resource.Resource
Exception: No ManagedConnections available within configured blocking timeout (300000[ms] ))
this means that the connection didn't returned to the pool but ithink i am properly closing the connections.
Here is my Database Connection Class
package database.dbConnection;
import java.sql.Connection;
import javax.sql.DataSource;
import javax.naming.*;
/**
* This class creates database connection
* and used for getting connection to the oracle database.
*/
public class DatabaseConnection{
public Connection con;
//Constructor
public DatabaseConnection(){ }
/**
* Method for getting connection
* @return Connection object.
* @param none.
*/
public Connection getConnection() {
try
{
// initializing the context.
Context context = new InitialContext();
// Lookng for DataSource object bounded by the JNDI Service
DataSource dataSource = (DataSource)context.lookup("java:/OracleDS");
// getting pooled connection.
con=dataSource.getConnection();
}
catch(Exception e)
{
System.out.println("Exception in: DatabaseConnection:removeConnection()" + e);
}
return con;
}
/**
* Method for removing connection
* @return none.
* @param none.
*/
public void removeConnection() throws Exception{
try
{
con.close();
}
catch(Exception e)
{
System.out.println("Exception in: DatabaseConnection:removeConnection()" + e);
}
}
}
and here is the code where i am closing the connections in my application which is in finally block
finally
{
if (flag==1)
{
con.rollback();
}
else
{
con.commit();
rowInserted=1;
}
//Removing oracle connection.
if(con!= null)
removeConnection();
}
So this is the problem. please help me as i have to meet the deadline of my project.
Thanx in advance
Deepak Sharma.