Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDBC connection error on a share Tomcat host

843859Oct 14 2007 — edited Oct 17 2007
Hello everyone,
I use a Shared Tomcat Java hosting to host my site and have below error message:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
	org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
	org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
	com.swlAdminJ.bo.AdminLoginBO.findByName(AdminLoginBO.java:30)
	com.swlAdminJ.action.login.LoginSubmitAction.execute(LoginSubmitAction.java:30)
	org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
	org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
	org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
	org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
But I don't have any problem to run on my local computer (I use Tomcat 5.5.25), and my site runs well on the local computer.

When I submit my question to the host, it said that 'The problem is obviously caused by wrong database connection setup' and recommmend me to read doc on 'http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html'. I found this paragraph in the page:


In addition, the names and values of all <env-entry> elements included in the web application deployment descriptor (/WEB-INF/web.xml) are configured into the initial context as well, overriding corresponding values from conf/server.xml only if allowed by the corresponding <Environment> element (by setting the override attribute to "true").


Does anyone know how to this 'override' attribute to "true"? where is it suppose to be? Is it the issue to cause the error?

Thanks in advance.

Here is my context.xml (under '/public_html/META-INF/') and part of web.xml (under '/public_html/WEB-INF/').
<?xml version="1.0" encoding="UTF-8"?>
<Context >
  <Resource
    name="jdbc/myDataSource"
    auth="Container"
    description="DB Connection"
    type="javax.sql.DataSource"
    driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/mydb?relaxAutoCommit=true"
    username="myusername"
    password="mypassword" 	  
    maxActive="20"
    maxIdle="2"
    maxWait="5000"
    validationQuery="select 1"
    />
  <WatchedResource>WEB-INF/web.xml</WatchedResource>
  <WatchedResource>META-INF/context.xml</WatchedResource>
</Context>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<resource-ref>
		<description>DB Connection</description>
		<res-ref-name>jdbc/myDataSource</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref> 	
......
</web-app>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2007
Added on Oct 14 2007
10 comments
1,184 views