jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes DBCP => Cannot create JDBC driver of class '' for connect URL 'null' Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "DBCP => Cannot create JDBC driver of class Watch "DBCP => Cannot create JDBC driver of class New topic
Author

DBCP => Cannot create JDBC driver of class '' for connect URL 'null'

Solmaz Anvar
Greenhorn

Joined: Jul 14, 2005
Posts: 26
I use dbcp with Tomcat5.0, Oracle9i jdbc driver (classes12.jar).

I put classes12.jar in $CATALINA_HOME/common/lib
----------------------------------------------------------------
server.xml

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

<ResourceParams name="jdbc/myoracle">
<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 racle:thin:myschema@127.0.0.1:1521:mysid</value>
</parameter>
<parameter>
<name>username</name>
<value>scott</value>
</parameter>
<parameter>
<name>password</name>
<value>tiger</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>

</GlobalNamingResources>
--------------------------------------------------------
web.xml

<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
-------------------------------------------------
my Code

Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();
---------------------------------------------------

but this error appeared:

Cannot create JDBC driver of class '' for connect URL 'null'

What is wrong?

Regards
soli



Solmaz Anvar
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Does it work if you try to get a connection using the same Driver and connection String from a simple JDBC program using DriverManager?

My suggestion...check that 'oracle.jdbc.driver.OracleDriver' is actually present in classes12.jar, and there is no spelling mistake. Also, you can try Oracle JDBC classes for Java 1.4 and later: It is called ojdbc.jar instead of classes12.jar.

HTH
Solmaz Anvar
Greenhorn

Joined: Jul 14, 2005
Posts: 26
Originally posted by Sonny Gill:
Does it work if you try to get a connection using the same Driver and connection String from a simple JDBC program using DriverManager?

My suggestion...check that 'oracle.jdbc.driver.OracleDriver' is actually present in classes12.jar, and there is no spelling mistake. Also, you can try Oracle JDBC classes for Java 1.4 and later: It is called ojdbc.jar instead of classes12.jar.

HTH


I tried this connection string with DriverManager.It work fine.
I use ojdbc.jar instead of classess12.jar and put <Resource> tag in <DefaultContext> but i have same error.

Help me
Thanks
Regards Soli


[ August 20, 2005: Message edited by: Solmaz Anvar ]
Narendran Gurubaran
Greenhorn

Joined: Feb 24, 2003
Posts: 3
Originally posted by Solmaz Anvar:


I tried this connection string with DriverManager.It work fine.
I use ojdbc.jar instead of classess12.jar and put <Resource> tag in <DefaultContext> but i have same error.

Help me
Thanks
Regards Soli



[ August 20, 2005: Message edited by: Solmaz Anvar ]



1) In the Context configuration, please change the property username to user.
2) Use oracle.jdbc.pool.OracleDataSourceFactory instead of org.apache.commons.dbcp.BasicDataSourceFactory

Here is the altered snippet....

<ResourceParams name="jdbc/myoracle">
<parameter>
<name>factory</name>
<value>oracle.jdbc.pool.OracleDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc racle:thin:myschema@127.0.0.1:1521:mysid</value>
</parameter>
<parameter>
<nameuser</name>
<value>scott</value>

It should work fine !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DBCP => Cannot create JDBC driver of class '' for connect URL 'null'
 
Similar Threads
Databse Connectivity Error
Is this true: JNDI equals Connection Pooling
db connection pooling to mssql from Tomcat 4.0.6
Tomcat Database Connection Pooling Error
Connection Pool problem in tomcat 5