wood burning stoves 2.0*
The moose likes Servlets and the fly likes urgent help (on oracle connection pool) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

urgent help (on oracle connection pool)

chennad
Greenhorn

Joined: Jun 26, 2002
Posts: 2
Hi,
I am using oracle connection pool ...I am getting new connection each time when i run jsp page ......
It is not getting the connection from pool .............
When i try to print connection object it is giving different object each time .......................
What is the wrong in my code ..............
Is any one using oracle connection pool ................
Please help me ...
Here is my code:

<%@page contentType="text/html"%>
<%@ page language="java" import="java.sql.*,oracle.jdbc.pool.*"%>
<html>
<head><title>JSP Page</title></head>
<body>
<%
Connection con= null;
DbConnectionPool dbcp=null;
dbcp=(DbConnectionPool)application.getAttribute("dbcp");
try{
if(dbcp == null)
{
dbcp=new DbConnectionPool();
application.setAttribute("dbcp",dbcp);
}
else
{
dbcp=(DbConnectionPool)dbcp;
}
con=dbcp.getDatabaseConnection();
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from checkout_checkin");
while(rs.next())
{
out.println(rs.getString(1)+"<br>");
}
stmt.close();
rs.close();
dbcp.closeDatabaseConnection(con);
}
catch (Exception e){System.out.println("eeeeeee==="+e);}
%>
</body>
</html>
*********************************
package oracle.jdbc.pool;
import oracle.jdbc.*;
import java.sql.*;
public class DbConnectionPool
{
OracleConnectionCacheImpl myConnectionPool;
OracleConnectionPoolDataSource myDataSource;

public DbConnectionPool()
{
try{
//Create & configure datasource
myDataSource = new OracleConnectionPoolDataSource();
myDataSource.setDriverType("thin");
myDataSource.setNetworkProtocol("tcp");
myDataSource.setServerName ("ipaddr");
myDataSource.setDatabaseName("xxxx");
myDataSource.setPortNumber (1521);
myDataSource.setUser ("xxxx");
myDataSource.setPassword ("xxxx");
//Create & configure pool
myConnectionPool = new OracleConnectionCacheImpl(myDataSource);
myConnectionPool.setMaxLimit(20);
myConnectionPool.setMinLimit(2);
myConnectionPool.setCacheScheme(OracleConnectionCacheImpl.DYNAMIC_SCHEME);
}catch (Throwable ex)
{
System.out.println("initConnectionPool() - Exception catched:"+ex);
}
}
public Connection getDatabaseConnection()
{
try{
return (Connection)myConnectionPool.getConnection();
}
catch (Throwable ex){ System.out.println("getDatabaseConnection()=="+ex); return null; }
}
public void closeDatabaseConnection(Connection connection)
{
try{
connection.close();
}catch (Throwable ex){
System.out.println("closeDatabaseConnection(Connection) - Exception catched: " +ex);
}
}
}

Thanks.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
chennad
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

also
Please do not cross post your questions to multiple forums. Most of the visitors here read in many of the forums and it is frustrating to see the same question repeated over and over. You have a better chance of getting a correct and timely answer if you post it to the most appropriate forum instead of using the shotgun approach and hoping you'll hit something.


Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urgent help (on oracle connection pool)
 
Similar Threads
Lost properties
oracle statement caching in connection pool
Converting servlet to a WebSphere JDBC datasource
urgent help (on oracle connection pool)
a mistake for bean