You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Zeeshan <Ze...@etechlogix.com> on 2002/09/27 00:55:13 UTC
JDBC Connnection Pool for Oracle
Hello :)
I am using Tomcat 4.0.4 with JDK1.4
I am getting the followig exception while creating the DataSource:
"javax.naming.NamingException: Cannot create resource instance"
Following is my code, server.xml and web.xml entries.
I will really appreciate if anyone can help me out here.
Thanx in advance
Zeeshan
Java Code
========
ctx = (Context) new InitialContext().lookup("java:comp/env");
if (ctx!=null) {
dataSource = (javax.sql.DataSource) ctx.lookup("jdbc/datasource");
connection = dataSource.getConnection();
}
Server.xml
========
<Resource name="jdbc/datasource" auth="Container" type="oracle.jdbc.pool.OracleDataSource"/>
<ResourceParams name="jdbc/datasource">
<parameter><name>username</name><value>test</value></parameter>
<parameter><name>password</name><value>test</value></parameter>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverName</name>
<value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
</parameter>
<parameter>
<name>url</name><value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
</parameter>
<parameter><name>maxActive</name><value>100</value></parameter>
<parameter><name>maxIdle</name><value>30000</value></parameter>
<parameter><name>maxWait</name><value>100</value></parameter>
</ResourceParams>
Web.xml
=======
<resource-ref>
<description>Resource reference to java.sql.Connection factory defined in server.xml </description>
<res-ref-name>jdbc/datasource</res-ref-name>
<res-type>oracle.jdbc.pool.OracleDataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Re: JDBC Connnection Pool for Oracle
Posted by Zeeshan <Ze...@etechlogix.com>.
miagi,
Yes, that's what I m doing now and it is working fine. I gave up on using
JNDI and now I realize that I don't really need to use JNDI.
I will also try your second alternative using dbConnectionBroker. This way
i can use it for nay database.
Thanx a lot.
Zeeshan
----- Original Message -----
From: "Luciano Kiniti Issoe" <mi...@hotmail.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, September 27, 2002 12:06 PM
Subject: Re: JDBC Connnection Pool for Oracle
Zeechan, I use this in my code and it works fine doing both pooling and
connection cache. Read more about it at the Oracle docs.
import oracle.jdbc.pool.*;
oracle.jdbc.pool.OracleConnectionPoolDataSource ocpds = new
OracleConnectionPoolDataSource();
ocpds.setURL(hotstring); // jdbc:oracle:oci8:@<SID> or
jdbc:oracle:thin:@<HOST>:<SID>
ocpds.setUser(user); //scott
ocpds.setPassword(password); //tiger
oracle.jdbc.pool.OracleConnectionCacheImpl occi = new
OracleConnectionCacheImpl(ocpds);
//set the caching size from 3 to 10 growing in a DYNAMIC SCHEME
(create connections as needed and closes then as they become uneeded )
occi.setMaxLimit(10);
occi.setMinLimit(3);
occi.setCacheScheme(OracleConnectionCacheImpl.DYNAMIC_SCHEME);
another option if you don't want to stick with Oracle your project's entire
life is using com.javaexchange.dbConnectionBroker.DbConnectionBroker,
you can find examples at http://www.javaexchange.com , but is simple as
follows:
// The below statement sets up a Broker with a minimun pool size of
2 connections
// and a maximum of 10. The log file will be created in
// /tmp/DBConnectionBroker.log and the pool connections will be
// restarted once a day.
DBConnectionBroker broker = new DBConnectionBroker(dbDriver, dbURL,
userId, password,2,10, "//tmp//DBConnectionBroker.log",1.0);
Connection conn = broker.getConnection();
hope it helps
Regards
miagi
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JDBC Connnection Pool for Oracle
Posted by Luciano Kiniti Issoe <mi...@hotmail.com>.
Zeechan, I use this in my code and it works fine doing both pooling and
connection cache. Read more about it at the Oracle docs.
import oracle.jdbc.pool.*;
oracle.jdbc.pool.OracleConnectionPoolDataSource ocpds = new
OracleConnectionPoolDataSource();
ocpds.setURL(hotstring); // jdbc:oracle:oci8:@<SID> or
jdbc:oracle:thin:@<HOST>:<SID>
ocpds.setUser(user); //scott
ocpds.setPassword(password); //tiger
oracle.jdbc.pool.OracleConnectionCacheImpl occi = new
OracleConnectionCacheImpl(ocpds);
//set the caching size from 3 to 10 growing in a DYNAMIC SCHEME
(create connections as needed and closes then as they become uneeded )
occi.setMaxLimit(10);
occi.setMinLimit(3);
occi.setCacheScheme(OracleConnectionCacheImpl.DYNAMIC_SCHEME);
another option if you don't want to stick with Oracle your project's entire
life is using com.javaexchange.dbConnectionBroker.DbConnectionBroker,
you can find examples at http://www.javaexchange.com , but is simple as
follows:
// The below statement sets up a Broker with a minimun pool size of
2 connections
// and a maximum of 10. The log file will be created in
// /tmp/DBConnectionBroker.log and the pool connections will be
// restarted once a day.
DBConnectionBroker broker = new DBConnectionBroker(dbDriver, dbURL,
userId, password,2,10, "//tmp//DBConnectionBroker.log",1.0);
Connection conn = broker.getConnection();
hope it helps
Regards
miagi
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JDBC Connnection Pool for Oracle
Posted by Zeeshan <Ze...@etechlogix.com>.
Felipe,
Actually that's what I am using currently, but it doesnt seem to do any
connection pooling:
Here is my existing code, but it is not doing any connection pooling.
oracleDataSource = new OracleDataSource(); // Set Oracle DataSource
oracleDataSource.setURL(getDbUrl());
oracleDataSource.setUser(getDbUser());
oracleDataSource.setPassword(getDbPassword());
connection = oracleDataSource.getConnection();
Am I doing anything wrong here? It has been working fine, just not doing
any connection pooling.
Thanx
Zeeshan
----- Original Message -----
From: "Felipe Schnack" <fe...@ritterdosreis.br>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, September 27, 2002 9:26 AM
Subject: Re: JDBC Connnection Pool for Oracle
Sorry... i forgot, but I found samples using google, and I don't have
the sources for that project.
Anyway, as far as I remember you can solve this using
oracle.jdbc.pool.OracleDataSource directly in your java code. This is
the connection pooling mechanism.
On Fri, 2002-09-27 at 13:13, Zeeshan wrote:
> Hi Felipe,
> Do you have any details or nay link about it?
> Zeeshan
>
>
>
> ----- Original Message -----
> From: "Felipe Schnack" <fe...@ritterdosreis.br>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Friday, September 27, 2002 5:19 AM
> Subject: Re: JDBC Connnection Pool for Oracle
>
>
> Why don't you use oracle's own pool implementation? I used it once, is
> quite good.
>
> On Thu, 2002-09-26 at 19:55, Zeeshan wrote:
> > Hello :)
> > I am using Tomcat 4.0.4 with JDK1.4
> > I am getting the followig exception while creating the DataSource:
> > "javax.naming.NamingException: Cannot create resource instance"
> >
> > Following is my code, server.xml and web.xml entries.
> > I will really appreciate if anyone can help me out here.
> >
> > Thanx in advance
> >
> > Zeeshan
> >
> > Java Code
> > ========
> > ctx = (Context) new InitialContext().lookup("java:comp/env");
> > if (ctx!=null) {
> > dataSource = (javax.sql.DataSource) ctx.lookup("jdbc/datasource");
> > connection = dataSource.getConnection();
> > }
> >
> > Server.xml
> > ========
> > <Resource name="jdbc/datasource" auth="Container"
> type="oracle.jdbc.pool.OracleDataSource"/>
> > <ResourceParams name="jdbc/datasource">
> > <parameter><name>username</name><value>test</value></parameter>
> > <parameter><name>password</name><value>test</value></parameter>
> >
>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDrive
> r</value></parameter>
> > <parameter>
> > <name>factory</name>
> > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> > </parameter>
> > <parameter>
> > <name>driverName</name>
> > <value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> > </parameter>
> > <parameter>
> >
> <name>url</name><value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> > </parameter>
> > <parameter><name>maxActive</name><value>100</value></parameter>
> > <parameter><name>maxIdle</name><value>30000</value></parameter>
> > <parameter><name>maxWait</name><value>100</value></parameter>
> > </ResourceParams>
> >
> > Web.xml
> > =======
> > <resource-ref>
> > <description>Resource reference to java.sql.Connection factory
> defined in server.xml </description>
> > <res-ref-name>jdbc/datasource</res-ref-name>
> > <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> >
> --
>
> Felipe Schnack
> Analista de Sistemas
> felipes@ritterdosreis.br
> Cel.: (51)91287530
> Linux Counter #281893
>
> Faculdade Ritter dos Reis
> www.ritterdosreis.br
> felipes@ritterdosreis.br
> Fone/Fax.: (51)32303328
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
--
Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893
Faculdade Ritter dos Reis
www.ritterdosreis.br
felipes@ritterdosreis.br
Fone/Fax.: (51)32303328
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JDBC Connnection Pool for Oracle
Posted by Felipe Schnack <fe...@ritterdosreis.br>.
Sorry... i forgot, but I found samples using google, and I don't have
the sources for that project.
Anyway, as far as I remember you can solve this using
oracle.jdbc.pool.OracleDataSource directly in your java code. This is
the connection pooling mechanism.
On Fri, 2002-09-27 at 13:13, Zeeshan wrote:
> Hi Felipe,
> Do you have any details or nay link about it?
> Zeeshan
>
>
>
> ----- Original Message -----
> From: "Felipe Schnack" <fe...@ritterdosreis.br>
> To: "Tomcat Users List" <to...@jakarta.apache.org>
> Sent: Friday, September 27, 2002 5:19 AM
> Subject: Re: JDBC Connnection Pool for Oracle
>
>
> Why don't you use oracle's own pool implementation? I used it once, is
> quite good.
>
> On Thu, 2002-09-26 at 19:55, Zeeshan wrote:
> > Hello :)
> > I am using Tomcat 4.0.4 with JDK1.4
> > I am getting the followig exception while creating the DataSource:
> > "javax.naming.NamingException: Cannot create resource instance"
> >
> > Following is my code, server.xml and web.xml entries.
> > I will really appreciate if anyone can help me out here.
> >
> > Thanx in advance
> >
> > Zeeshan
> >
> > Java Code
> > ========
> > ctx = (Context) new InitialContext().lookup("java:comp/env");
> > if (ctx!=null) {
> > dataSource = (javax.sql.DataSource) ctx.lookup("jdbc/datasource");
> > connection = dataSource.getConnection();
> > }
> >
> > Server.xml
> > ========
> > <Resource name="jdbc/datasource" auth="Container"
> type="oracle.jdbc.pool.OracleDataSource"/>
> > <ResourceParams name="jdbc/datasource">
> > <parameter><name>username</name><value>test</value></parameter>
> > <parameter><name>password</name><value>test</value></parameter>
> >
> <parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDrive
> r</value></parameter>
> > <parameter>
> > <name>factory</name>
> > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> > </parameter>
> > <parameter>
> > <name>driverName</name>
> > <value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> > </parameter>
> > <parameter>
> >
> <name>url</name><value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> > </parameter>
> > <parameter><name>maxActive</name><value>100</value></parameter>
> > <parameter><name>maxIdle</name><value>30000</value></parameter>
> > <parameter><name>maxWait</name><value>100</value></parameter>
> > </ResourceParams>
> >
> > Web.xml
> > =======
> > <resource-ref>
> > <description>Resource reference to java.sql.Connection factory
> defined in server.xml </description>
> > <res-ref-name>jdbc/datasource</res-ref-name>
> > <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> >
> --
>
> Felipe Schnack
> Analista de Sistemas
> felipes@ritterdosreis.br
> Cel.: (51)91287530
> Linux Counter #281893
>
> Faculdade Ritter dos Reis
> www.ritterdosreis.br
> felipes@ritterdosreis.br
> Fone/Fax.: (51)32303328
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893
Faculdade Ritter dos Reis
www.ritterdosreis.br
felipes@ritterdosreis.br
Fone/Fax.: (51)32303328
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JDBC Connnection Pool for Oracle
Posted by Zeeshan <Ze...@etechlogix.com>.
Hi Felipe,
Do you have any details or nay link about it?
Zeeshan
----- Original Message -----
From: "Felipe Schnack" <fe...@ritterdosreis.br>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Friday, September 27, 2002 5:19 AM
Subject: Re: JDBC Connnection Pool for Oracle
Why don't you use oracle's own pool implementation? I used it once, is
quite good.
On Thu, 2002-09-26 at 19:55, Zeeshan wrote:
> Hello :)
> I am using Tomcat 4.0.4 with JDK1.4
> I am getting the followig exception while creating the DataSource:
> "javax.naming.NamingException: Cannot create resource instance"
>
> Following is my code, server.xml and web.xml entries.
> I will really appreciate if anyone can help me out here.
>
> Thanx in advance
>
> Zeeshan
>
> Java Code
> ========
> ctx = (Context) new InitialContext().lookup("java:comp/env");
> if (ctx!=null) {
> dataSource = (javax.sql.DataSource) ctx.lookup("jdbc/datasource");
> connection = dataSource.getConnection();
> }
>
> Server.xml
> ========
> <Resource name="jdbc/datasource" auth="Container"
type="oracle.jdbc.pool.OracleDataSource"/>
> <ResourceParams name="jdbc/datasource">
> <parameter><name>username</name><value>test</value></parameter>
> <parameter><name>password</name><value>test</value></parameter>
>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDrive
r</value></parameter>
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> <parameter>
> <name>driverName</name>
> <value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> </parameter>
> <parameter>
>
<name>url</name><value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> </parameter>
> <parameter><name>maxActive</name><value>100</value></parameter>
> <parameter><name>maxIdle</name><value>30000</value></parameter>
> <parameter><name>maxWait</name><value>100</value></parameter>
> </ResourceParams>
>
> Web.xml
> =======
> <resource-ref>
> <description>Resource reference to java.sql.Connection factory
defined in server.xml </description>
> <res-ref-name>jdbc/datasource</res-ref-name>
> <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
--
Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893
Faculdade Ritter dos Reis
www.ritterdosreis.br
felipes@ritterdosreis.br
Fone/Fax.: (51)32303328
--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JDBC Connnection Pool for Oracle
Posted by Felipe Schnack <fe...@ritterdosreis.br>.
Why don't you use oracle's own pool implementation? I used it once, is
quite good.
On Thu, 2002-09-26 at 19:55, Zeeshan wrote:
> Hello :)
> I am using Tomcat 4.0.4 with JDK1.4
> I am getting the followig exception while creating the DataSource:
> "javax.naming.NamingException: Cannot create resource instance"
>
> Following is my code, server.xml and web.xml entries.
> I will really appreciate if anyone can help me out here.
>
> Thanx in advance
>
> Zeeshan
>
> Java Code
> ========
> ctx = (Context) new InitialContext().lookup("java:comp/env");
> if (ctx!=null) {
> dataSource = (javax.sql.DataSource) ctx.lookup("jdbc/datasource");
> connection = dataSource.getConnection();
> }
>
> Server.xml
> ========
> <Resource name="jdbc/datasource" auth="Container" type="oracle.jdbc.pool.OracleDataSource"/>
> <ResourceParams name="jdbc/datasource">
> <parameter><name>username</name><value>test</value></parameter>
> <parameter><name>password</name><value>test</value></parameter>
> <parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> <parameter>
> <name>driverName</name>
> <value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> </parameter>
> <parameter>
> <name>url</name><value>jdbc:oracle:thin:@localhost:1521:ORACLE</value>
> </parameter>
> <parameter><name>maxActive</name><value>100</value></parameter>
> <parameter><name>maxIdle</name><value>30000</value></parameter>
> <parameter><name>maxWait</name><value>100</value></parameter>
> </ResourceParams>
>
> Web.xml
> =======
> <resource-ref>
> <description>Resource reference to java.sql.Connection factory defined in server.xml </description>
> <res-ref-name>jdbc/datasource</res-ref-name>
> <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
>
--
Felipe Schnack
Analista de Sistemas
felipes@ritterdosreis.br
Cel.: (51)91287530
Linux Counter #281893
Faculdade Ritter dos Reis
www.ritterdosreis.br
felipes@ritterdosreis.br
Fone/Fax.: (51)32303328
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>