Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Tomcat JDBC Connection Pool not working

843854Sep 29 2003 — edited Sep 30 2003
I read the tutorial for setting Tomcat's connection pool at their website, I practily copied what's in there and it doesn't work.

I search the net AND this forum and I'm getting the exact same error message as a lot of users, but there are no replies with solutions, can anyone help me with this?

here's what I added inside the <Context> on my server.xml file:

<Resource name="promocoesDataSource" auth="Container"
type="javax.sql.DataSource"/>

<ResourceParams name="promocoesDataSource">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@vile:1531:D00PP192</value>
</parameter>
<parameter>
<name>username</name>
<value>*** the username here ***</value>
</parameter>
<parameter>
<name>password</name>
<value>*** the password here ***</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>

this is what I added in my web.xml file:

<resource-ref>
<description>DataSource Promo��es</description>
<res-ref-name>promocoesDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

this is the code I'm using to access the pool and get the connection:
	InitialContext iniCtx = new InitialContext ();
	Context context = (Context)iniCtx.lookup("java:/comp/env");
	DataSource ds = (DataSource)context.lookup ("promocoesDataSource");
	return ds.getConnection();
this is the exception I get:

org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:167)
javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:301)
org.apache.naming.NamingContext.lookup(NamingContext.java:834)
org.apache.naming.NamingContext.lookup(NamingContext.java:194)
util.db.oracle.DAO.getContainerConnection(DAO.java:39)
util.db.oracle.DAO.getConnection(DAO.java:54)
promo.Promocao.getLista(Promocao.java:82)
org.apache.jsp.login$jsp._jspService(login$jsp.java:214)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
... etc etc etc ....
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 28 2003
Added on Sep 29 2003
6 comments
1,004 views