You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shyly Amarasinghe <am...@dpw.com> on 2003/04/16 20:18:04 UTC

Cannot load JDBC driver class

Hello.

I am trying to use datasources with Tomcat but get an error message "java.sql.SQLException: Cannot load JDBC driver class 'null' "

server.xml contains the following:
      <parameter>
        <name>driverClassName</name>
        <value>com.sybase.jdbc2.jdbc.SybDriver</value>
      </parameter>

the webapp's web.xml contains:
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/mydb</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>
	
and the jsp page contains
	DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mydb");
     con = ds.getConnection();  //this is where it fails

When I check if ds == null, it's not null, but at the con = ds.getConnection() I get the error message.

The driver jar is in %CATALINA_HOME%\common\lib and %CATALINA_HOME%\shared\lib, and I've set the classpath to include jconn2.jar, and the following code works, so I think I've got everything set up properly.
Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance(); 
String url = "jdbc:sybase:xxxx:5000";
Connection con1 = DriverManager.getConnection(url, "xxx", "xxx"); 

Can you see why my datasources aren't working? 

Thanks very much for any help you can offer,
Shyly


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Cannot load JDBC driver class

Posted by Rick Fincher <rn...@tbird.com>.
Hi,

What is your database URL?  I got that error when it could not open my
database.  It has to be of the form "jdbc:(etc.)"  You can set your debug
level higher like in the HOWTO to get a better data dump in the log file to
see what's going on.  Be sure to enable the creation of a
logs/localhost_db_log file.

Rick

----- Original Message -----

> Hello.
>
> I am trying to use datasources with Tomcat but get an error message
"java.sql.SQLException: Cannot load JDBC driver class 'null' "
>
> server.xml contains the following:
>       <parameter>
>         <name>driverClassName</name>
>         <value>com.sybase.jdbc2.jdbc.SybDriver</value>
>       </parameter>
>
> the webapp's web.xml contains:
>   <resource-ref>
>       <description>DB Connection</description>
>       <res-ref-name>jdbc/mydb</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>   </resource-ref>
>
> and the jsp page contains
> DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/mydb");
>      con = ds.getConnection();  //this is where it fails
>
> When I check if ds == null, it's not null, but at the con =
ds.getConnection() I get the error message.
>
> The driver jar is in %CATALINA_HOME%\common\lib and
%CATALINA_HOME%\shared\lib, and I've set the classpath to include
jconn2.jar, and the following code works, so I think I've got everything set
up properly.
> Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
> String url = "jdbc:sybase:xxxx:5000";
> Connection con1 = DriverManager.getConnection(url, "xxx", "xxx");
>
> Can you see why my datasources aren't working?
>
> Thanks very much for any help you can offer,
> Shyly
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org