-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: MySQL Cannot load JDBC driver class 'null'
PostPosted: Wed Nov 05, 2003 2:43 pm 
Newbie

Joined: Tue Nov 04, 2003 3:04 pm
Posts: 4
I keep getting the following error:

Cannot open connection: Cannot load JDBC driver class 'null'

I am using Tomcat 5 and MySQL 4.1, I only pasted the relevant entry for the server.xml file.

I do not understand why Hibernate is not finding the driver. I downloaded the most current driver and have tried both the org and com version in the binary I installed.

Thanks,
Nelm

_____________________________________________________________________


web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com//dtd/web-app_2_3.dtd">

<web-app>

<servlet>
<servlet-name>testServ</servlet-name>
<servlet-class>testServ</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServ</servlet-name>
<url-pattern>/testServ</url-pattern>
</servlet-mapping>

<resource-ref>
<description>
JNDI DataSource for example database
</description>
<res-ref-name>jdbc/quickstart</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Sharable</res-sharing-scope>
</resource-ref>



</web-app>

server.xml

<Context path="/quickstart" docBase="quickstart">
<Resource name="jdbc/quickstart" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/quickstart">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<!-- DBCP database connection settings -->
<parameter>
<name>url</name>
<value>jdbc:mysql:///quickstart</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>DriverName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>ucl_user</value>
</parameter>
<parameter>
<name>password</name>
<value>ucl_user</value>
</parameter>

<!-- DBCP connection pooling options -->
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
</ResourceParams>
</Context>


hibernate.cfg..xml

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>

<session-factory>

<property name="connection.datasource">java:comp/env/jdbc/quickstart</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- Mapping files -->
<mapping resource="Cat.hbm.xml"/>

</session-factory>

</hibernate-configuration>


Top
 Profile  
 
 Post subject: host in jdbc url and opening datasource?
PostPosted: Wed Nov 05, 2003 7:09 pm 
Regular
Regular

Joined: Sun Sep 21, 2003 11:43 pm
Posts: 85
Location: Massachusetts
1. Don't you need to specify the host name in your jdbc url?
Maybe:
jdbc:mysql://localhost/quickstart
OR IP?
jdbc:mysql://127.0.0.1/quickstart

2. I tried using DataSources under Struts months ago but I think I remember something about having to open the datasource like so:

javax.sql.DataSource dataSource;
java.sql.Connection myConnection;
try {
dataSource = getDataSource(request);
myConnection = dataSource.getConnection();
// do what you wish with myConnection
} catch (SQLException sqle) {
getServlet().log("Connection.process", sqle);
} finally {
//enclose this in a finally block to make
//sure the connection is closed
try {
myConnection.close();
} catch (SQLException e) {
getServlet().log("Connection.close", e);
}
}


(that was from http://jakarta.apache.org/struts/faqs/database.html but it is generic enough code to apply here).

Are you doing that? How are you opening your datasource for a connection?

Regards,
David


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.