Problem loading jdbc driver in Tomcat

Hi,
I have got a connection to MySQL5.0 from TomCat 5.5.13, that was test correctly in development (JSC Upd 1) but I encounter the following deployment error :
com.sun.rave.web.ui.appbase.ApplicationException: org.apache.jasper.JasperException: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
When I verify, I found that if I put the mysql Connector JDBC driver in <tomcat>/common/lib, there is no error.
But when the MySql Connector JDBC driver resides in <tomcat>/shared/lib, the error persists.
What's the difference ? shouldn't it work for both ?
Thanks in advance for any pointers and advise.

hmm... i guess that it's a must to include the lib at /common/lib instead of shared/lib .
Is there a Tomcat resource that I can read up on ?
rgds

Similar Messages

  • Beginner Has Problem With Loading JDBC Driver Using MySQL

    Hi, I am having problem with loading JDBC driver, and need your diagnotic help.
    1. I have installed MySQL (C:\mysql), created a databse (soup), and created a littel table (VIDEOS). I am able to see the table in the console:
    sql> select * from videos
    2. I have downloaded the latest version of Connector/J (mysql-connector-java-3.1.0-alpha.zip), and unzip the zip file into my C:\ directory.
    3. I copied the mysql-connector-java-3.1.0-alpha-bin.jar to the C:\j2sdk1.4.1_02\jre\lib\ext folder and it is in my CLASSPATH
    4. MySQL server is running
    C:\> C:\mysql\bin\mysqld-nt --standalone
    5. open another DOS window and use the database
    mysql>USE SOUP
    6. succesfully compiled a Java program (javac Test.java):
    import java.sql.* ;
    public class Test
    public static void main( String[] args )
    try
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    try
    Connection con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/soup" );
    try
    Statement statement = con.createStatement();
    ResultSet rs = statement.executeQuery("SELECT TITLE FROM VIDEOS");
    while ( rs.next() )
    System.out.println( rs.getString( "TITLE" ) );
    rs.close();
    statement.close();
    catch ( SQLException e )
    System.out.println( "JDBC error: " + e );
    finally
    con.close();
    catch( SQLException e )
    System.out.println( "could not get JDBC connection: " + e );
    catch( Exception e )
    System.out.println( "could not load JDBC driver: " + e );
    7. when I run the Java program (java Test), I got
    the message:
    could not load JDBC driver: java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    What am I missing?

    Hi,
    I missed to specify test in my last post.
    Try running your program by explicitly setting the classspath when
    running your program . java -classpath c:\mysql-connector-java-3.1.0-alpha-bin.jar test
    Make sure your jar file contains org.gjt.mm.mysql.Driver class

  • I have a problem with JDBC Realm in Tomcat/Oracle/Win XP

    I have a problem with JDBC Realm in Tomcat.
    I have attached my server.xml file located in the
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\server.xml
    The Problem is that when I login I get the user name and password prompt but it does not resolve.
    When I enter in the tomcat-users.xml password with memory realm uncommented it works fine.
    C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\tomcat-users.xml
    Is there a cache or something I need to reset for the JDBC Realm to work?
    I have attached my tables and contents as well...
    Did I miss something????
    Thanks
    Phil
    server.xml
    <Server port="8005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
    <!-- Global JNDI resources -->
    <GlobalNamingResources>
    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
    </GlobalNamingResources>
    <!-- Define the Tomcat Stand-Alone Service -->
    <Service name="Catalina">
    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector
    port="8080" maxHttpHeaderSize="8192"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" redirectPort="8443" acceptCount="100"
    connectionTimeout="20000" disableUploadTimeout="true" />
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009"
    enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />
    <!-- Define the top level container in our container hierarchy -->
    <Engine name="Catalina" defaultHost="localhost">
    <!--
    <Realm className="org.apache.catalina.realm.MemoryRealm" />
    -->
    <Realm className="org.apache.catalina.realm.JDBCRealm"
    driverName="oracle.jdbc.driver.OracleDriver"
    connectionURL="jdbc:oracle:thin:@localhost:1521:orcl"
    connectionName="testName" connectionPassword="testPass"
    userTable="users"
    userNameCol="user_name"
    userCredCol="user_pass"
    userRoleTable="user_roles"
    roleNameCol="role_name" />
    <!-- Define the default virtual host
    Note: XML Schema validation will not work with Xerces 2.2.
    -->
    <Host name="localhost" appBase="webapps"
    unpackWARs="true" autoDeploy="true"
    xmlValidation="false" xmlNamespaceAware="false">
    </Host>
    </Engine>
    </Service>
    </Server>
    Tables
    create table users
    user_name varchar(15) not null primary key,
    user_pass varchar(15) not null
    create table roles
    role_name varchar(15) not null primary key
    create table user_roles
    user_name varchar(15) not null,
    role_name varchar(15) not null,
    primary key( user_name, role_name )
    select * from users;
    ----------------------+
    | user_name | user_pass |
    ----------------------+
    | tomcat | tomcat |
    | user1 | tomcat |
    | user2 | tomcat |
    | user3 | tomcat |
    ----------------------+
    select * from roles;
    | role_name |
    | tomcat |
    | role1 |
    select * from user_roles;
    -----------------------+
    | role_name | user_name |
    -----------------------+
    | tomcat | user1 |
    | role1 | user2 |
    | tomcat | tomcat |
    | role1 | tomcat |
    -----------------------+

    Jan 2, 2008 11:49:35 AM org.apache.coyote.http11.Http11Protocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    Jan 2, 2008 11:49:35 AM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 734 ms
    Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.5.9
    Jan 2, 2008 11:49:35 AM org.apache.catalina.realm.JDBCRealm start
    SEVERE: Exception opening database connection
    java.sql.SQLException: oracle.jdbc.driver.OracleDriver
         at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm.java:684)
         at org.apache.catalina.realm.JDBCRealm.start(JDBCRealm.java:758)
         at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1004)
         at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
         at org.apache.catalina.core.StandardService.start(StandardService.java:450)
         at org.apache.catalina.core.StandardServer.start(StandardServer.java:683)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:537)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:271)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:409)
    Jan 2, 2008 11:49:35 AM org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    Jan 2, 2008 11:49:36 AM org.apache.catalina.core.StandardContext resourcesStart

  • Java.sql.SQLException: Cannot load JDBC driver class 'null'

    Hi,
    I am a beginner of using jdbc, i use the tomcat4.1.x, mysql3.23.54 and it's jdbc driver 2.0.14. I place the drive <in jar file> in tomcat/commons/lib and configure the server.xml, web.xml and some testing coding. But there are some error like the following:
    java.sql.SQLException: Cannot load JDBC driver class 'null'
         at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:529)
         at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:312)
         at foo.DBTest.init(DBTest.java:18)
         at org.apache.jsp.test_jsp._jspService(test_jsp.java:48)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
    of course its some of the error code and there are more.
    Why I have this problems and how can I fix it? Can someone help me??
    Thanks,
    Tong
    I place my test.jsp at tomcat/webapps/DBTest and DBTest.java at tomcat/webapps/DBTest/WEB-INF/classes/foo
    additional of the tomcat/conf/server.xml
    <Resource name="TestDB" auth="Container" type="javax.sql.DataSource" description="MySQL TestDB"/>
    <ResourceParams name="TestDB">
    <parameter><name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter><name>maxActive</name><value>10</value></parameter>
    <parameter><name>maxIdle</name><value>1</value></parameter>
    <parameter><name>maxWait</name><value>10000</value></parameter>
    <parameter><name>username</name><value>javauser</value></parameter>
    <parameter><name>password</name><value>javadude</value></parameter>
    <parameter>
    <name>driverClassName</name>
    <value>org.gjt.mm.mysql.Driver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/javatest?autoReconnect=true</value>
    </parameter>
    </ResourceParams>
    tomcat/webapps/DBTest/WEB-INF/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>
    <description>MySQL Test App</description>
    </web-app>

    Post the part of your code that loads the driver and connects. My guess is you are using a variable for the name of the driver and the variable has not been set to anything(intially set to null).
    Thanks
    Cardwell

  • Problem with JDBC driver for Oracle 10g

    Hi.
    I've successfully accessed a MySQL database via a DataSource from a servlet (that uses a DAO). However, when I try to do the same with an Oracle 10g Database, I get the error message:
    Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
    I'm using J2SE1.5.0/5.0 and ojdbc14.jar, the latter of which I downloaded this afternoon as the latest driver JAR available on the Oracle site. As with the MySQL driver, I've placed it in the commons\lib folder within Tomcat. (I've also, of course, made the necessary modifications to server.xml and web.xml.)
    Upon examining the ReadMe file at the top of the Oracle download page, I found that the oracle.jdbc.driver package is now deprecated and all references to oracle.jdbc.driver should be replaced with oracle.jdbc. However, I got a similar error message when I tried this modification. Upon examining the contents of ojdbc.jar, I found that the driver was there and that it was, in fact, still oracle\jdbc\driver\OracleDriver!
    It appears as though the Oracle site has not been updated with a driver that matches its latest documentation. However, this does not explain why the driver is not even being loacted when it is in the correct place. Can anybody shed any light on this? Any help would be much appreciated.
    Thanks in anticipation.
    Cheers.
    Jan

    I've successfully accessed a MySQL database via a
    DataSource from a servlet (that uses a DAO). However,
    when I try to do the same with an Oracle 10g
    Database, I get the error message:
    Cannot load JDBC driver class 'oracle.jdbc.driver.OracleDriver'
    That's different from a ClassNotFoundException.
    >
    I'm using J2SE1.5.0/5.0 and ojdbc14.jar, the latter
    of which I downloaded this afternoon as the latest
    driver JAR available on the Oracle site. So you got ojdbc14.jar or ojdbc14_g.jar under the 10g drivers?
    As with the
    MySQL driver, I've placed it in the commons\lib
    folder within Tomcat. I think it's a better idea to put in the WEB-INF/lib directory of your Web app rather than commons/lib. WAR files are a very good idea, too.
    (I've also, of course, made the
    necessary modifications to server.xml and web.xml.)So you're using a JNDI data source? It sounds to me like that's where the problem is.
    You should not have to edit the server.xml at all. If you put the <ResourceParams> in a context XML file with the same name as your WAR file into the TOMCAT_HOME/webapps directory it'll be picked up automatically. (It might also be accessible in the META-INF directory for your app, but I haven't done it that way.)
    Upon examining the ReadMe file at the top of the
    Oracle download page, I found that the
    oracle.jdbc.driver package is now deprecated and all
    references to oracle.jdbc.driver should be replaced
    with oracle.jdbc.
    However, I got a similar error
    message when I tried this modification. Upon
    examining the contents of ojdbc.jar, I found that the
    driver was there and that it was, in fact, still
    oracle\jdbc\driver\OracleDriver! The fully-resolved class name you should be using MUST match the class that's in the ojdbc14.jar that you're using. Look in the JAR for the definitive answer: the one that I downloaded is still using the oracle.jdbc.driver package for OracleDriver.class. Ignore the docs - use the name that's in the JAR.
    It appears as though the Oracle site has not been
    updated with a driver that matches its latest
    documentation. That often happens with docs.
    However, this does not explain why the
    driver is not even being loacted when it is in the
    correct place. Can anybody shed any light on this?
    Any help would be much appreciated.I think the problem lies in your web.xml and server.xml
    I'd recommend that you decouple the JDBC from the Web app for now. See if you can connect to Oracle using a simple desktop app and leave the Web piece out of the equation for now. Once you can do that, you'll be certain that the parameters you're using are correct and you can turn your attention to getting the Tomcat configuration right.
    PS - I'm using Oracle 9.2.0.1 and Tomcat successfully right now, so it can be done.

  • Cannot load JDBC Driver Class in Tomcat5.5 using struts.

    Hello to all,
    I'm working in the struts environment using Esclipse3.2 IDE.
    And I have installed Tomcat5.5 server.I have created the LoginForm
    in struts.Now i like to connect my LoginForm with MySql database.I
    have also created the database in MySql naming strutsdatabase.
    I had also download the mysql-connector-java-3.0.16-ga-bin.jar and
    save that in C:/tomcat/commons/lib directory.
    While running I have got the below error:
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:598)
    at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:808)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
    at javax.servlet.GenericServlet.init(GenericServlet.java:211)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
    Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    javax.servlet.UnavailableException: Initializing application data source org.apache.struts.action.DATA_SOURCE
    at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:812)
    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:335)
    at javax.servlet.GenericServlet.init(GenericServlet.java:211)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
    And I have attached my struts-config.xml:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software
    Foundation//DTD Struts Configuration 1.2//EN"
    "http://struts.apache.org/dtds/struts-config_1_2.dtd">
    <struts-config>
    <data-sources>
    <data-source
    type="org.apache.tomcat.dbcp.dbcp.BasicDataSource">
    <set-property property="url"
    value="jdbc:mysql://localhost:3306/strutsdatabase?autoReconnect
    =true"/>
    <set-property property="driverClassName"
    value="com.mysql.jdbc.Driver"/>
    <set-property property="username" value=""/>
    <set-property property="password" value=""/>
    <set-property property="maxActive" value="10"/>
    <set-property property="validationQuery" value="SELECT
    COUNT(*) FROM test"/>
    <set-property property="maxWait" value="5000"/>
    <set-property property="defaultAutoCommit" value="false"/>
    </data-source>
    </data-sources>
    <form-beans>
    <form-bean name="LoginForm"
    type="fino.web.struts.action.LoginForm"/>
    </form-beans>
    <global-exceptions/>
    <global-forwards/>
    <action-mappings>
    <action name="LoginForm" path="/login" scope="request"
    type="fino.web.struts.action.LoginAction" validate="true">
    <forward name="success" path="/success.jsp"/>
    <forward name="failure" path="/failure.jsp"/>
    </action>
    </action-mappings>
    <controller/>
    <message-resources null="false"
    parameter="org.apache.struts.action.ActionResources"/>
    </struts-config>
    Friends,please help me to find solution to this problem.

    Note: This thread was originally posted in the [Java Compiler|http://forums.sun.com/forum.jspa?forumID=7] forum, but moved to this forum for closer topic alignment.

  • Urgent... unable to load JDBC driver

    i have developed a servlet which will establish connection to mySQL.. but it couldn't load the JDBC driver even i placed
    [ mysql-connector-java-2.0.14-bin.zip ] in [ C:\j2sdk1.4.2_05\jre\lib\ext\ ]
    in fact.. it work fine b4 i format my notebook.. anyone can help me??
    pls note that i using APACHE TOMCAT and mySQL 3.23
    pls help.. very urgent one
    the following is my servlet code.....
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    public class LoginServlet extends HttpServlet {
    static final String dbURL = "jdbc:mysql://localhost" ;
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    Connection conn = null;
    String nextJSP = null;
    try {
    Class.forName("org.gjt.mm.mysql.Driver");
    catch (ClassNotFoundException e) {
    throw new ServletException("Unable to load JDBC driver");
    }

    i already add new variable in environment variables
    variable name = CLASSPATH
    variable value = C:\j2sdk1.4.2_05\jre\lib\ext\mysql-connector-java-2.0.14-bin.jar;
    but the same output is come up.. still unable to load my JDBC driver in TOMCAT... y?

  • Load JDBC-Driver dynamically with JarClassLoader

    Hey!
    I have a problem loading JDBC drivers dynamically with a JarClassLoader:
    Code:
    public class URLLoaderTest {
      public static void main(String[] args) {
      try {
        URL[] urlList = {new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\mssqlserver.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msbase.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msutil.jar").toURL()};
        ClassLoader classLoader = new URLClassLoader(urlList);
        Class c = Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver",true,classLoader);
        Object d = c.newInstance();
        DriverManager.registerDriver((Driver)d);
        // DriverManager.getDrivers()    Enumeration is empty
        Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://Server:1433","test","test");
        DatabaseMetaData meta = conn.getMetaData();
        System.out.println("JDBC driver version is " + meta.getDriverVersion());
      catch (Exception e) {System.out.println(e.getMessage());}
    }Problem:
    Till the DriverManager registraton everything is ok.
    The registerDriver Method throws no exception but if I call DriverManager.getDrivers() after calling the registerDriver Method an empty Enumeration is returned.
    So the driver is not loaded and DriverManager.getConnection throws an Exception (no suitable driver).
    If I include the driver jars into the Classpath everything is running (but that isn't what I want to do).
    Is there a solution for this problem? Maybe it is possible to load the data into the AppClassLoader??!!
    Thanx in advance.

    Found a solution!
    For everyone who is interested:
    public class URLLoaderTest {
      public static void main(String[] args) {
      try {
        URL[] urlList = {new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\mssqlserver.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msbase.jar").toURL(),
                         new File("D:\\jbuilder5\\SQLServerJDBC\\lib\\msutil.jar").toURL()};
        ClassLoader classLoader = new URLClassLoader(urlList);
        Class c = Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver",true,classLoader);
        Object d = c.newInstance();
        Driver driver = (Driver)d;
        Properties prop = new Properties();
        prop.setProperty("user","test");
        prop.setProperty("password" ,"test");
        Connection conn = driver.connect("jdbc:microsoft:sqlserver://test:1433",prop);
        System.out.println("JDBC driver version is " + meta.getDriverVersion());
      catch (Exception e) {System.out.println(e.getMessage());}
    }

  • Java.sql.SQLException: Cannot load JDBC driver

    THis topic has been discussed many many times but I still not able to connect to Oracle 8i from my servlet using Tomcat 4.1.12 on hp-ux and java1.3
    I always got: java.sql.SQLException: Cannot load JDBC driver class 'null'
    In server.xml:
    <Context Path="/MyApp" docBase="MyApp" debug="0" reloadable="true" >
    <Resource name="jdbc/ora" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/ora" >
    <parameter>
    <name>username</name>
    <value>myname</value>
    </parameter>
    <parameter> <name>password</name>
    <value>mypassword</value>
    </parameter>
    <parameter> <name>driverClassName</name>
    <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:oracle:thin:@myhostname:1521:ora</value>
    </parameter> </ResourceParams>
    </Context>
    In MyApp/WEB-INF/web.xml:
    <resource-ref>
    <res-ref-name>jdbc/ora</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    The Oracle jdbc jar file classes12.jar is under common/lib in Tomcat's home. read Permission is there.
    In the servlet:
    init(ServletConfig config):
    Context init = new InitialContext();
    Context ctx = (Context) init.lookup("java:comp/env");
    dataSource = (DataSource) ctx.lookup("jdbc/acdb");
    doPost(..)
    the error occured at :
    synchronized (dataSource){
    con = dataSource.getConnection();}
    Thanks in advance!

    Everything looks correct to me, except for one thing.
    In your web.xml you have this:
    <res-ref-name>jdbc/ora</res-ref-name> In your server.xml, you have this tag, which matches your web.xml:
    <ResourceParams name="jdbc/ora" > But in your Java code, you've got this:
    dataSource = (DataSource) ctx.lookup("jdbc/acdb"); When I've successfully set up a Web app data source, all three names had to agree. You either need to change your Java lookup name to "jdbc/ora" or change the web.xml and server.xml to "jdbc/acdb".
    See if that does it. Everything else sounds correct to me. - MOD

  • Can't load jdbc driver in servlet

    Dear All,
    I have tried to connect to MS SQL SERVER 2000 through JDBC DRIVER FOR
    SQLSERVER. However I receieved an error: can't load jdbc driver class:
    null.
    The following steps were what I did:
    1.Set up SQL Server and create a few tables and users.
    2.Config Server.xml
    Add the following codes in /tomcat/conf/Server.xml
    <Context path="/persistence" docBase="persistence" debug="0"
    reloadable="true">
              <Resource name="jdbc/persistenceDB" auth="Container"
    type="javax.sql.DataSource"/>
              <ResourceParams name="jdbc/PersistenceDB">
                   <Parameter>
                        <name>user</name>
                        <value>kitty</value>
                   </Parameter>
                   <Parameter>
                        <name>password</name>
                        <value>abc</value>
                   </Parameter>
                   <Parameter>
                        <name>driverClassName</name>
                        <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
                   </Parameter>
                   <Parameter>
                        <name>url</name>
    <value>jdbc:microsoft:sqlserver://localhost:1433;databaseName=persistence;selectMethod=cursor;</value>
                   </Parameter>
              </ResourceParams>               
    </Context>
    3.Config my web application's web.xml
    Added the following piece of code in WEB.XML
    <resource-ref>
    <res-ref-name>jdbc/persistenceDB</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    4.Use Datasource in my code
    package persistence.database;
    import java.sql.*;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    import javax.servlet.ServletContext;
    import persistence.*;
    import com.microsoft.jdbcx.sqlserver.*;
    import javax.naming.Context;
    public class DatabaseAuthenticator implements Authenticator {
    private DataSource ds;
    public void init(ServletContext sctx) throws Exception {
    InitialContext init = new InitialContext();
    try{
         Context ctx = (Context) init.lookup("java:/comp/env");
    ds = (DataSource) ctx.lookup("jdbc/persistenceDB");
    } catch (Exception e) { e.printStackTrace();
    public User authenticate(String username, String password)
    throws AuthenticationException, UnknownException {
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs;
    try {
    if (ds != null) {System.out.println("Success to get
    datasource");
            } else {System.out.println("Failed");}
    System.out.println(ds.toString());
    try
    conn = ds.getConnection();     
    catch (Exception e)
    e.printStackTrace();
    pstmt = conn.prepareStatement("SELECT user_id " + .........
    5. put msutil.jar, mssqlserver.jar and msbase.jar under /tomcat/common/lib/.
    When I tried to run the program, I receieved an error: can't load jdbc
    driver class: null.
    I've got no idea what's going on.
    Any Suggestion?
    Thanks in advance
    Kitty

    Hi Kitty,
    The connection you're trying to set up points to nothing :
    Connection conn = null;
    So, you receive a complaint that that driver cannot be loaded. Please read
    http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html
    download the right database driver and use that. Good luck!
    Wouter van Reeven
    public User authenticate(String username, String
    g password)
    throws AuthenticationException, UnknownException
    ption {
    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs;

  • Initialization error: Loading jdbc driver

    Hi ,
    In a file-XI-JDBC scenario, i am getting this error. "Initialization error: Loading jdbc driver 'com.microsoft.jdbc.sqlserver.SQLServerDriver' failed: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver".
    but i have installed/deployed third party SQL driver on J2ee server thru SDM.
    Can any one sort out this problem.
    Rgds
    Sridhar

    Hi,
    try looking into the log viewer in Vsual Administrator. Usually you can find more information about the problem there.
    Also try redeploying the driver again.
    cheers,
    naveen

  • Load JDBC driver class 'null'

    hi all :)
    i'm using a datasource (tomcat 4.1.18 with jdk 1.4)
    i'm the following error :
    java.sql.SQLException: Cannot load JDBC driver class 'null'my classes12.jar find in $CATALINA_HOME/common/lib
    where is ma error ?
    thanks a lot.

    GlobalNamingResources?
    I sent up a data source for each app, like this:
    <Context    path="/api-prototype"
                docBase="api-prototype.war"
                debug="1"
                reloadable="true"
                crossContext="true"
                useNaming="true">
        <Logger className="org.apache.catalina.logger.FileLogger"
                prefix="localhost-api-prototype-log."
                suffix=".txt"
                timestamp="true"/>
        <Resource   name="jdbc/APIPrototype"
                    auth="Container"
                    type="javax.sql.DataSource"/>
    <!-- Oracle 9.2.0.1 data source -->
        <ResourceParams name="jdbc/APIPrototype">
            <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:oracle:thin:@elvis:1521:CAPP</value>
            </parameter>
            <parameter>
                <name>username</name>
                <value>api</value>
            </parameter>
            <parameter>
                <name>password</name>
                <value>mod</value>
            </parameter>
            <parameter>
                <name>maxActive</name>
                <value>20</value>
            </parameter>
            <parameter>
                <name>maxIdle</name>
                <value>0</value>
            </parameter>
            <parameter>
                <name>maxWait</name>
                <value>60000</value>
            </parameter>
            <parameter>
                <name>removeAbandoned</name>
                <value>true</value>
            </parameter>
            <parameter>
                <name>removeAbandonedTimeout</name>
                <value>300</value>
            </parameter>
        </ResourceParams>
    </Context>This works fine on Tomcat 4.1.24. I don't know where you got that example from, but I'd recommend that you look at the Tomcat JNDI How-to:
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
    Why go anywhere else? - MOD

  • Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver

    Hi,
    i am doing a forum application.
    i am trying to connect database connection through javax.sql.DataSource.
    I am using Eclipse editor for developing this application and i am using sql server 2000 database.
    i have create a servlet file.
    here is the coding.
    DatabaseGetConnection.java
    `````````````````````````````````````````
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletOutputStream;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.sql.DataSource;
    public class DatabaseGetConnection extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
    private Connection con=null;
    private DataSource ds=null;
    public DatabaseGetConnection() throws ServletException {
    super();               
    public DatabaseGetConnection(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
    this.doPost(req, res);          
    public void init() throws ServletException {
    try
    final Context initContext = new InitialContext();
    final Context envContext = (Context)initContext.lookup("java:/comp/env");
    this.ds = (DataSource)initContext.lookup("jdbc/mySQLServer");
    }catch(final NamingException ne)
    ne.printStackTrace();
    }catch(final Exception e)
    e.printStackTrace();
    public DataSource getDS()
    System.out.println("Datasource method calling");
    if (this.ds!=null)
    System.out.println("Datasource not null");
    }else
    System.out.println("Datasource null");
    return this.ds;
    public Connection getCon()
    try
    this.con=this.getDS().getConnection();
    if (this.con!=null)
    System.out.println("Connection Successfull");
    }catch(final SQLException se)
    System.out.print("Connection Establishment Error : ");
    se.printStackTrace();
    return this.con;
    I have configured server.xml. here is the configuration
    server.xml
    ````````````````
    <GlobalNamingResources>
    <Resource name="jdbc/mySQLServer" global="jdbc/mySQLServer" auth="Container"
    type="javax.sql.DataSource" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
    url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=forum;SelectMethod=cursor"
    username="sa" password="sa" maxActive="20" maxIdle="10"
    maxWait="-1"/>
    </GlobalNamingResources>
    here is the web.xml file
    ``````````````````````````````````
    <resource-ref>
    <res-ref-name>jdbc/mySQLServer</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    is this configuration correct? plz help me about the configuration and coding through Eclipse.
    i have run the application and i got the error. here is the error details
    org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.jdbc.sqlserver.SQLServerDriver'
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
    at com.forum.database.DatabaseGetConnection.getCon(DatabaseGetConnection.java:85)
    at com.forum.database.DatabaseGetConnection.GetAllTopicSearch(DatabaseGetConnection.java:101)
    at org.apache.jsp.test_jsp._jspService(test_jsp.java:73)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:760)
    ... 24 more
    thanks and regards,
    k.s.kumar

    Please don't multipost, it's rude: http://forum.java.sun.com/thread.jspa?threadID=5219591
    Please continue on that thread.

  • Cannot load JDBC driver class 'com.mysql.jdbc.Driver'

    Hi,
    At the moment I'm trying to get an example working. The error message I get is:
    Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.mysql.jdbc.Driver'"
    The example I tried is http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html.
    Configuration:
    Wampserver 2.0 (Apache, MySQL, PHP for Windows XP), Tomcat 6.0 and jdk1.6.0_03.
    The following files are installed in %CATALINA_HOME%/webabbs/
    - Dbtest/test.jsp
    - Dbtest/WEB-INF/web.xml
    - Dbtest/WEB-INF/lib/standard.jar
    - Dbtest/WEB-INF/lib/tomcat-dbcp.jar
    - Dbtest/WEB-INF/lib/jstl.jar
    Tia,
    Abel.

    Hi,
    I added the jar file containing the requested class to my lib directory. So the current contents of that directory is:
    The following files are installed in %CATALINA_HOME%/webabbs/
    - Dbtest/test.jsp
    - Dbtest/WEB-INF/web.xml
    - Dbtest/WEB-INF/lib/standard.jar
    - Dbtest/WEB-INF/lib/tomcat-dbcp.jar
    - Dbtest/WEB-INF/lib/jstl.jar
    - Dbtest/WEB-INF/lib/mysql-connector-java-5.1.5-bin.jar
    More importantly, I started my Wamp server.
    The example works as it should have. Thanks for the feedback.
    Abel

  • Failed to load JDBC driver

    I am trying to run a program and keep getting the error Failed to load JDBC driver. java.lang.ClassNotFoundException
    How can I correct this?

    I was just trying to execute this example from Deitel's Java book.
    import java.awt.*;
    import java.sql.*;
    import java.util.*;
    import javax.swing.*;
    public class DisplayAuthors extends JFrame {
       // JDBC driver name and database URL
       static final String JDBC_DRIVER = "com.ibm.db2j.jdbc.DB2jDriver";
       static final String DATABASE_URL = "jdbc:db2j:books";
       // declare Connection and Statement for accessing
       // and querying database
       private Connection connection;
       private Statement statement;
       // constructor connects to database, queries database, processes
       // results and displays results in window
       public DisplayAuthors()
          super( "Authors Table of Books Database" );
          // connect to database books and query database
          try {
             // specify location of database on filesystem
             System.setProperty( "db2j.system.home", "C:/Cloudscape_5.0" );
             // load database driver class
             Class.forName( JDBC_DRIVER );
             // establish connection to database
             connection = DriverManager.getConnection( DATABASE_URL );
             // create Statement for querying database
             statement = connection.createStatement();
             // query database
             ResultSet resultSet =
                statement.executeQuery( "SELECT * FROM authors" );
             // process query results
             StringBuffer results = new StringBuffer();
             ResultSetMetaData metaData = resultSet.getMetaData();
             int numberOfColumns = metaData.getColumnCount();
             for ( int i = 1; i <= numberOfColumns; i++ )
                results.append( metaData.getColumnName( i ) + "\t" );
             results.append( "\n" );
             while ( resultSet.next() ) {
                for ( int i = 1; i <= numberOfColumns; i++ )
                   results.append( resultSet.getObject( i ) + "\t" );
                results.append( "\n" );
             // set up GUI and display window
             JTextArea textArea = new JTextArea( results.toString() );
             Container container = getContentPane();
             container.add( new JScrollPane( textArea ) );
             setSize( 300, 100 );  // set window size
             setVisible( true );   // display window
          }  // end try
          // detect problems interacting with the database
          catch ( SQLException sqlException ) {
             JOptionPane.showMessageDialog( null, sqlException.getMessage(),
                "Database Error", JOptionPane.ERROR_MESSAGE );
             System.exit( 1 );
          // detect problems loading database driver
          catch ( ClassNotFoundException classNotFound ) {
             JOptionPane.showMessageDialog( null, classNotFound.getMessage(),
                "Driver Not Found", JOptionPane.ERROR_MESSAGE );           
             System.exit( 1 );
          // ensure statement and connection are closed properly
          finally {
             try {
                statement.close();
                connection.close();           
             // handle exceptions closing statement and connection
             catch ( SQLException sqlException ) {
                JOptionPane.showMessageDialog( null,
                   sqlException.getMessage(), "Database Error",
                   JOptionPane.ERROR_MESSAGE );
                System.exit( 1 );
       }  // end DisplayAuthors constructor
       // launch the application
       public static void main( String args[] )
          DisplayAuthors window = new DisplayAuthors();     
          window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    }  // end class DisplayAuthors

Maybe you are looking for

  • Connection Errors

    I'm running 10.4 server (currently 10.4.2 but I've had the same problems on 10.4.4 and 10.4.7) as an internet gateway and content filter. I'm running DNS, DHCP, NAT, Squid Proxy Server and Dan's Guardian content filter. Starting recently, I've been h

  • In Lion, can I hide the address book without the application closing?

    In Snow Leopard, when I clicked the red circle in the upper left-hand corner of the address book, the application automatically hid without closing entirely. In Lion, the same action closes the application so every time I need to use it, the address

  • Gradient interlocking circular arrows in Illustrator

    hi there- I was wondering how you make interlocking circular arrows similar to this in Illustrator: I can do the circular arrows one of two ways: create a circular outline, split into 3, put arrow heads on, make them a fill and add gradient OR create

  • Transcation code for error messages

    hi all, what is the transaction code for getting the system error messages?And how can I create my own error messages? for eg: in a program, i want to show an error message to the user when the data is not showing up properly. thnx,

  • To DaveyB re: variable data might not have been initialised

    I tried to reply to your thread but got a server error. It's not happening for other threads, and I don't know if others are experiencing the same problem. If you don't get a response within the next hour, try posting again, or just reply here. In th