This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Solmaz Anvar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic