Two Laptop Bag*
The moose likes Tomcat and the fly likes Connecting to database in Tomcat 5.5 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 » Products » Tomcat
Bookmark "Connecting to database in Tomcat 5.5" Watch "Connecting to database in Tomcat 5.5" New topic
Author

Connecting to database in Tomcat 5.5

Todd Baxter
Greenhorn

Joined: Sep 26, 2007
Posts: 18
I have Tomcat 5.5.23 and the following in my

server.xml
----------

<Resource name="jdbc/mytest"
auth="Container"
type="org.apache.commons.dbcp.BasicDataSource"
maxActive="16"
maxWait="2000"
username="scott"
password="tiger" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbcracle:thin:@localhost:1521:pbz01"
/>


web.xml
-------

<resource-ref>
<res-ref-name>
jdbc/mytest
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>



and here's the error I get when I do this..

Context envCtx = (Context) new InitialContext().lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/mytest");
return ds.getConnection();


Error
------

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Do you have an oracle driver named something like oraclejdbc-1.4.jar in your build path?

mine is in the lib folder for my web application, but I've seen it in tomcat/common and tomcat/server

In any case, you must reference that jar file (in your classpath or build.xml) to find the driver
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connecting to database in Tomcat 5.5
 
Similar Threads
Cannot create JDBC driver
Can't get connection from DataSource object
Cannot create JDBC driver of class '' for connect URL 'null'
struts 1.3 Data base connection pool
jpa, datasource and tomcat