dcsimg
Problem with oracle connection pool (urgent please)
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   cc_venkat
Posted On:   Tuesday, July 23, 2002 01:56 PM

JSP Page Hi, I am using oracle connection pool in my application .... When i say con.close() some times it is throwing exception and it is not working properly ... Is the way i am using oracle connection pool is correct? The connections are not reusing and if i reach max connections i am getting error ............. package oracle.jdbc.pool; import oracle.jdbc.driver.*; import oracle.jdbc.pool.*; import java.sql.*; public class GonehomeDBPool extends Object { private static GonehomeDBPool pool = null; private OracleConnectionCacheImpl myConnectionPool=null;    More>>
JSP Page

Hi,

I am using oracle connection pool in my application ....


When i say con.close() some times it is throwing exception and it is not working properly ...


Is the way i am using oracle connection pool is correct?
The connections are not reusing and if i reach max connections i am getting error .............




package oracle.jdbc.pool;



import oracle.jdbc.driver.*;


import oracle.jdbc.pool.*;


import java.sql.*;




public class GonehomeDBPool extends Object


{
private static GonehomeDBPool pool = null;


private OracleConnectionCacheImpl myConnectionPool=null;


private OracleConnectionPoolDataSource myDataSource=null;



private GonehomeDBPool()


{


try{


//Create oracle datasource instance


myDataSource = new OracleConnectionPoolDataSource();


// Set connection parameters


myDataSource.setDriverType("thin");


myDataSource.setNetworkProtocol("tcp");


myDataSource.setServerName("ipaddress");


myDataSource.setDatabaseName("xxxx");


myDataSource.setPortNumber(1521);


myDataSource.setUser("xxxx");


myDataSource.setPassword("xxx");



//Create & configure pool
myConnectionPool = new OracleConnectionCacheImpl(myDataSource);


myConnectionPool.setMaxLimit(10);


myConnectionPool.setMinLimit(3);




myConnectionPool.setCacheScheme(OracleConnectionCacheImpl.FIXED_RETURN_NULL_SCHEME);



}catch (Exception ex)
{


System.out.println("GonehomeDBPool()- Exception catched :"+ex);


}
}


public static GonehomeDBPool getPool()
{


if(pool == null)


{
pool=new GonehomeDBPool();
System.out.println("GonehomeDBPool getPool()==="+pool);


}
return pool;


}


public Connection getDatabaseConnection()
{


try{


return (Connection)myConnectionPool.getConnection();


}
catch (Exception exp)


{


System.out.println("getDatabaseConnection()=="+exp);


return null;


}


}


public static void closeConnection(Connection connection)


{
try{


connection.close();


}catch (Throwable exep)


{


System.out.println("closeDatabaseConnection(connection) - Exception catched: " +exep);


}


}
public int getActiveNumberOfConnections()


{
return myConnectionPool.getActiveSize();


}

public int getCacheNumberOfConnections()


{
return myConnectionPool.getCacheSize();


}

}
*******************************************


The above code i am using in the following jsp code :


<%@page contentType="text/html"%>


<%@ page import="java.sql.*,oracle.jdbc.pool.GonehomeDBPool" %>






<%
GonehomeDBPool ghPool=null;


Connection con=null;


try
{


ghPool=GonehomeDBPool.getPool(); // creating connection pool


con=ghPool.getDatabaseConnection(); // getting logical connection from pool ........


Statement stmt=con.createStatement();


ResultSet rs=stmt.executeQuery("select count(*) from checkout_checkin");


while(rs.next())


{
j=rs.getInt(1);


}
stmt.close();


rs.close();


out.println("j======"+j);


}
catch (Exception e){System.out.println("eeeeeee==="+e);}
finally


{


con.close();



}
%>




****************************


when i say con.close() i am getting some times

erorr ................
Is the way i am using connection pool is correct ?

   <<Less
About | Sitemap | Contact