TOMCAT Datasource configuration problem
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Girinath_SVS
Posted On:   Monday, February 2, 2004 06:35 AM

Hi all, I'm trying to write a servlet that will loaded by Tomcat 5.0.16 and retrieve data fom an oracle 8i DB. here is my configuration and code : My server.xml contains : factory org.apache.commons.dbcp.BasicDataSourceFactory url jdbc:oracle:thin:@myTnsEntry validationQuery maxIdle 2 maxActive 4 driverClassName oracle.jdbc.driver.OracleDriver maxWait 5000 user scott password tiger My web.xml contains : my description jdbc/mydb javax.sql.DataSource Container The simplified code in my servlet is: ServletContext sc=getServletContext(); Context initCt   More>>

Hi all,

I'm trying to write a servlet that will loaded by Tomcat 5.0.16 and retrieve data fom an oracle 8i DB. here is my configuration and code :
My server.xml contains :


factory org.apache.commons.dbcp.BasicDataSourceFactory
url jdbc:oracle:thin:@myTnsEntry
validationQuery
maxIdle 2
maxActive 4
driverClassName oracle.jdbc.driver.OracleDriver
maxWait 5000
user scott
password tiger



My web.xml contains :

my description
jdbc/mydb
javax.sql.DataSource
Container


The simplified code in my servlet is:
ServletContext sc=getServletContext();
Context initCtx = new InitialContext();
envName="java:comp/env";
Context envCtx = (Context) initCtx.lookup(envName);
if(envCtx==null) {
sc.log("lookup(""+envName+"") returns null");
return;
} else {
sc.log("test5>GetMvt.init> lookup(""+envName+"") OK");
}
envName="jdbc/mydb";
DataSource ds=(DataSource)envCtx.lookup(envName);
if(obj==null) {
sc.log("lookup(""+envName+"") returns null");
return;
} else {
sc.log("lookup(""+envName+"") OK");
}
Connection conn = ds.getConnection();

This does not work !!! i've got the trace "lookup java:comp/env OK" and a NamingException is thrown with the message "driverClassName is requiered".

I experimented too:
- I droped classes12.jar (I suppressed the javaxsql from the.jar) in %CATALINA_HOME%commonlib.
- I tried with the entries either 'driverName' or 'URL' in the server.wml.
- I tried to set url with either "jdbc:oracle:oci8:@myTnsEntry" or "jdbc:oracle:thin:@myTnsEntry".
- I downloaded latest releases of commons-dbcp.jar and commons-pool.jar
- I tested with the type 'oracle.jdbc.pool.OracleDataSource' and the factory 'oracle.jdbc.pool.OracleDataSourceFactory' instead of 'javax.sql.DataSource'.

Before I tried to use DataSources, I had this code and it worked :
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:oci8:@myTnsEntry","scott","tiger");
statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);

None of these experiments does work. If someone has any idea, just tell me. It will be a really great pleasure for me.

Thanks a lot

Girinath

   <<Less
About | Sitemap | Contact