tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@shareowner.com
Subject RE: JNDI + Tomcat + Oracle 9i Database
Date Tue, 25 Feb 2003 19:37:08 GMT
This issue has been asked and answered again and again in the mailing list
of tomcat, struts, and commons. Consider that Oracle is so populate, setup
should be pretty straightforward.

My advice is to make sure that you have read carefully the tomcat datasource
documentation.

My environment is

J2sdk 1.4.1_01 <= 1.4
Tomcat 4.1.18
Apache 2.0.44
Tomcat Connector 2.0.3
Red Hat Linux 7.2 (prod)
Windows 2000 (dev)
Oracle 8.1.7
classes12.jar <= 1.2

1. Below is part of my context. Do not invent the resource type, driver, and
factory. I saw someone use a different factory or driver think they are
going to utilize Oracle's pooling. It is smart but it is wrong in this case.
To prove it is wrong, read Tomcat source code.

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

<ResourceParams name="jdbc/abcd">
<parameter>
	<name>driverClassName</name>
	<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
	<name>url</name>
	<value>jdbc:oracle:thin:@oratest.int.abcd.com:1521:PROD</value>
</parameter>

2. Also in my app's web.xml

<resource-ref>
	<description>Oracle Datasource</description>
	<res-ref-name>jdbc/abcd</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
</resource-ref>

Do not put commons-dbcp and pooling jars in your app's WEB-INF/lib, use
Tomcat's (in common/lib).

3. Initialize the connection pool and get connection:

Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:comp/env");
DataSource dataSource = (DataSource) envContext.lookup("jdbc/abcd");
dataSource.getConnection()

Don't do anything other than point 3 to get the connection or driver.

I have had two problems before:

- null driver: renamed classes12.zip to classes12.jar and put it ONLY in
commons/lib.
- cannot connect: use a real url other than Microsoft's name, so oratest
won't work on linux while oratest.mydomain.com works.
- cast exception: use commons dbcp and pooling in commons/lib.


Regards,
 
 
PQ
 
"This Guy Thinks He Knows Everything"
"This Guy Thinks He Knows What He Is Doing"

-----Original Message-----
From: "Sebastião Carlos Santos" [mailto:scarlosantos@bol.com.br] 
Sent: February 25, 2003 1:37 PM
To: tomcat-user@jakarta.apache.org
Subject: Re: JNDI + Tomcat + Oracle 9i Database

When I made the change of the <name>url </ name> for <name>URL </ name>
I
started to receive the following error message  
Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' it goes
connect URL 'null'  
Going back to the configuration <name>url </ name>  
Cannot create JDBC driver of class 'oracle.jdbc.driver.OracleDriver' it goes
connect URL 'jdbc:oracle:thin@ged.ufu.br:1521:GED'

Taking advantage of the opportunity, which driver JDBC should use,
ojdbc14.jar (for the jdk 1.4) or classes12.zip, that should have the name
according to the documentation changed for classes12.jar

Sebastião Carlos Santos
Oracle Database Administrator 
Universidade Federal de Uberlândia - UFU
Gratificação de Estímulo à Docência - GED



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message