I've configured a datasource for oracle under tomcat 5, but when i try to get a connection i receive this error "org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null', cause: No suitable driver".When i debug my code i note that the datasource returned after lookup has null properties (for instance the driver class property is null).
This is my web.xml:
************************
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/MyOracleDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
************************
This is my servlet code:
************************
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/env");
String s = "jdbc/MyOracleDataSource";
DataSource ds = (DataSource)envContext.lookup(s);
System.out.println(s);
Connection conn = ds.getConnection();
************************
and this is my server.xml:
************************
<Resource name="jdbc/MyOracleDataSource" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/MyOracleDataSource">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>password</name>
<value>pronto</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc
racle:thin:@ihx0074:1521:INA</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>username</name>
<value>cassa</value>
</parameter>
</ResourceParams>
************************
Can anyone tell me why it doesn't work ?
Thank you.