Oracle Database and Tomcat 4.1.8 JNDI connection pooling notes. (still
refining)
I recently needed to grab data from a Oracle 9i DB from tomcat 4.1.18. While
I was seting it up, I created some notes that I think may help you and/or
others on this list. Note, I'm still refining these notes, because I will
be doing this many more time in the near future.
Oracle 9i and Tomcat 4.1.18 JNDI setup points: (added a few 8i differences
also)
1) Oracle 9i works with ojdbc14.jar. Oracle 8i used classes12.jar.
(Note: must use a JAR extention not a zip!)
2) The location to place the Oracle specific JAR (see above) in Tomcat
4.x is C:\jakarta-tomcat-4.1.18\common\lib\* (again this needs to be a JAR
not a ZIP file)
3) A common mistake is to place the Resource/ and ResourceParams/
server.xml elements either in the wrong context/ element or not in one at
all. This will produce an Exception similar to: java.sql.SQLException:
Cannot load JDBC driver class 'null'
Note:
I have seen people say you should Use
oracle.jdbc.pool.OracleConnectionPoolDataSource instead of
oracle.jdbc.driver.OracleDriver for the driverClassName parameter inside the
server.xml configuration file. For example:
parameter
namedriverClassName/name
valueoracle.jdbc.pool.OracleConnectionPoolDataSource/value
/parameter
But both seem to work for me? So Im still investigating.
MISC links to other helpful Oracle JNDI setup info:
http://forum.java.sun.com/thread.jsp?forum=48thread=267528
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-how
to.html
Example of the required server.xml configuration:
Context path=/goldendata docBase=goldendata debug=0
reloadable=true crossContext=true
!-- # DATASOURCE #--
Resource name=jdbc/GoldenDB auth=Container
type=javax.sql.DataSource/
ResourceParams name=jdbc/GoldenDB
parameter
namefactory/name
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
parameter
namedriverClassName/name
!--valueoracle.jdbc.driver.OracleDriver/value--
valueoracle.jdbc.pool.OracleConnectionPoolDataSource/value
/parameter
parameter
nameurl/name
valuejdbc:oracle:thin:localhost:1521:TestDB/value
/parameter
parameter
nameusername/name
valuespaz/value
/parameter
parameter
namepassword/name
values/value
/parameter
!--parameter
namedriverName/name
valuejdbc:oracle:thin:localhost:1521:TestDB/value
/parameter --
parameter
namemaxActive/name
value20/value
/parameter
parameter
namemaxIdle/name
value10/value
/parameter
parameter
namemaxWait/name
value-1/value
/parameter
/ResourceParams
!-- ###--
/Context
Example of using this Oracle 8-9i connection pool inside your Java source co
de:
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup(java:/comp/env);
DataSource ds = (DataSource)envContext.lookup(jdbc/GoldenDB);
Connection conn = ds.getConnection();
- Original Message -
From: Andoni [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Wednesday, March 19, 2003 4:57 AM
Subject: Oracle - JNDI - Pooling - classes12.zip
Hello,
Could someone please post a chunck of their server.xml and web.xml where
they are using tomcat 4.0 and classes12.jar and Oracle and have
successfully
implemented connection pooling.
I have a huge history of postings to this group and many questions on this
subject but no right answers!
Otherwise a few answers to questions will also help:
1. Are Tyrex classes12.jar mutually exclusive (i.e. do they do the same
job, the both implement DataSource.class)?
2. In the namedriverName/namevalue?/value Should this be the full
connection URL?
Please help as I am going demented and the documentation is v. vague.
Andoni.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]