Can't load jdbc driver from localhost

I'm having problems loading the jdbc driver from localhost when using a java com object in ASP.
The simple class compiles fine and runs perfect from dos command line but gives this exception when run from personal webserver:
java.lang.ClassNotFoundException: sun/jdbc/odbc/JdbcOdbcDriver
Obviously, it is not finding the jdbc driver, but what is the problem? It finds the driver when run from dos locally. Do I need a 3rd party driver when using as a COM object?
Here is a code snippet:
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection TestConnection = DriverManager.getConnection("jdbc:odbc:systemDSN", "username", "password");
Any help is appreciated, thanks!

I don't think it's exactly a classpath problem. I think when you run from the DOS command line, you are using the java.exe program that contains Sun's JVM and all the associated classes including sun/jdbc/odbc/JdbcOdbcDriver. But when you use this Java COM object (which I am not familiar with), if it doesn't find that class then it must be using the Microsoft VM, which naturally doesn't include that class you are having a problem with.

Similar Messages

  • 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;

  • Can't load JDBC Driver

    Hi,
    I can't load my JDBC driver for SQLserver database to
    opening my DB with a servlet ...
    platform : Windows 2000 server
    servlet container : Jakarta-tomcat 3.2.2
    jdk : jdk1.3
    After executing the servlet which load the JDBC driver, the following message was appearing:
    "ClassNotFoundException, java.lang.NullPointerException"
    Thanks for your help.

    Looks like the servlet is not able to find the required class in the package...Tomcat rewrites the classpath....So you might want to look at /bin/tomcatEnv.bat     and modify it accordingly....Of course, check your classpath env variable to see if all the necessary zip/jar files are included.

  • Loading JDBC-Driver from a JSP

    Hi,
    i want to load a JDBC-Driver fromout my JSP-File, so i used:
    Class.forName("org.postgresql.Driver");
    but when i start it i get a ClassNotFoundException...
    my jsp-file and the org-directory are stored in
    <tomcat-dir>\webapps\examples\
    so both in the same directory...
    any ideas why i cannot load it?
    thx anyway
    cu Errraddicator

    it still does not work...
    now i can load the driver, but when i call the DriverManager to establish a connection i get a sqlexception with the message "no suitable driver"...
    but why? i�ve loaded the driver and normally it registeres itself at the driver-manager, but it doesn�t...
    any ideas?
    thx anyway
    cu Errraddicator

  • I can't load some content from my external hard drive to itunes,

    I can't load some content from 1 of my external hard drive to itunes, it can see it and try to load the folder / files but it doesn't appear, these files worked recently as some of them are currently on my ipod touch - I had to factory restore my laptop this week (virus) so have been trying to put everything back on to sync ipod - any ideas???

    To delete files from your external HDD, attach it to your MBP and drag the unwanted files to trash and then empty trash.
    Then you select the files that you want to transfer by 'drag and drop' to the external HDD and trash the files on your MBP.
    Ciao.

  • Error loading JDBC driver

    Hi,
    I have an rpt file developed in crystal report 2008. it connects to SQL Server using ODBC(RDO) connection. I have a jsp file that needs to change the datasource to use JDBC (JNDI). The scriptlet for changing datasource is given below. I have my sqljdbc.jar in the web-inf\lib folder of my application as well as in \server\{server_name}\lib folder. when I try to run the jsp it gives me error as follows :
    ERROR [com.businessobjects.reports.sdk.JRCCommunicationAdapter]  detected an exception: Error loading JDBC driver.  The class 'com.microsoft.jdbc.sqlserver.SQLServerDriver' could not be found.
         at com.crystaldecisions.reports.queryengine.Connection.t1(Unknown Source)
         at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.a(Unknown Source)
         at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.for(Unknown Source)
         at com.crystaldecisions.reports.reportdefinition.ReportHelper.a(Unknown Source)
         at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.long(Unknown Source)
         at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.a(Unknown Source)
         at com.businessobjects.reports.sdk.requesthandler.ReportViewingRequestHandler.byte(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.do(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.if(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.a(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.a(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter$2.call(Unknown Source)
         at com.crystaldecisions.reports.common.ThreadGuard.syncExecute(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.for(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.int(Unknown Source)
         at com.businessobjects.reports.sdk.JRCCommunicationAdapter.request(Unknown Source)
         at com.businessobjects.sdk.erom.jrc.a.a(Unknown Source)
         at com.businessobjects.sdk.erom.jrc.a.execute(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.RemoteAgent$a.execute(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.CommunicationChannel.a(Unknown Source)
         at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ds.a(Unknown Source)
         at com.crystaldecisions.sdk.occa.report.application.ReportSource.a(Unknown Source)
         at ....
    <br>
    <br>
    Scriptlet :
    <%
    //Report can be opened from the relative location specified in the CRConfig.xml, or the report location
    //tag can be removed to open the reports as Java resources or using an absolute path (absolute path not recommended
    //for Web applications).
    final String DBUSERNAME = "sa";
    final String DBPASSWORD = "password";
    final String CONNECTION_STRING = "!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=;user=;password=";
    final String TRUSTEDCON = "false";
    final String PREQESERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433";
    final String SERVERTYPE = "JDBC (JNDI)";
    final String DATABASE_DLL = "crdb_jdbc.dll";
    final String DATABASE = "bssc";
    final String DBCLASSNAME = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    final String USEJDBC = "true";
    final String DATABASE_NAME = "bssc";
    final String SERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433";
    final String CONNECTIONURL = "jdbc:microsoft:sqlserver://localhost:1433";
    final String SERVER = "localhost";
    %>
    <%          
              final Logger logger = Logger.getLogger(ReportAction.class.getName());
              final String REPORT_NAME = "../reports/Krt.rpt";
    try {
              ReportClientDocument oReportClientDocument = new ReportClientDocument();
              oReportClientDocument.open(REPORT_NAME, 0);
         // Create the two connectioninfo objects to use
         IConnectionInfo oldConnectionInfo =  new ConnectionInfo();
         IConnectionInfo newConnectionInfo = new ConnectionInfo();
         // Assign the old Connection info to the reports current info
         DatabaseController dbController = oReportClientDocument.getDatabaseController();
         oldConnectionInfo = dbController.getConnectionInfos(null).getConnectionInfo(0);                                       
         // If this connection needed parameters, we would use this field.      
         Fields pFields = null;
         // Create a new propertybag for the new location
         PropertyBag boPropertyBag1 = new PropertyBag();
         // Set new table logon properties
         boPropertyBag1.put("JDBC Connection String", CONNECTION_STRING);
         boPropertyBag1.put("Trusted_Connection", TRUSTEDCON);
         boPropertyBag1.put("PreQEServerName", PREQESERVERNAME);
         boPropertyBag1.put("Server Type", SERVERTYPE);
         boPropertyBag1.put("Database DLL", DATABASE_DLL);
         boPropertyBag1.put("Database", DATABASE);
         boPropertyBag1.put("Database Class Name", DBCLASSNAME);
         boPropertyBag1.put("Use JDBC", USEJDBC);
         boPropertyBag1.put("Database Name", DATABASE_NAME);
         boPropertyBag1.put("Server Name", SERVERNAME);
         boPropertyBag1.put("Connection URL", CONNECTIONURL);
         boPropertyBag1.put("Server", SERVER);
         // Assign the properties to the connection info
         newConnectionInfo.setAttributes(boPropertyBag1);
         // Set the DB Username and Pwd
         newConnectionInfo.setUserName(DBUSERNAME);
         newConnectionInfo.setPassword(DBPASSWORD);
         // The Kind of connectionInfos is SQL
         newConnectionInfo.setKind(ConnectionInfoKind.SQL);
         // set the parameters to replace.
         // The 4 options are:
         // _doNotVerifyDB
         // _ignoreCurrentTableQualifiers
         // _mapFieldByRowsetPosition
         // _useDefault 
         int replaceParams = DBOptions._ignoreCurrentTableQualifiers + DBOptions._doNotVerifyDB;
         // Now replace the connections      
         dbController.replaceConnection(oldConnectionInfo, newConnectionInfo, pFields, replaceParams);
    %>
    <%
    //Report can be opened from the relative location specified in the CRConfig.xml, or the report location
    //tag can be removed to open the reports as Java resources or using an absolute path (absolute path not recommended
    //for Web applications).
    final String DBUSERNAME = "sa";
    final String DBPASSWORD = "password";
    final String CONNECTION_STRING = "!com.microsoft.jdbc.sqlserver.SQLServerDriver!jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=;user=;password=";
    final String TRUSTEDCON = "false";
    final String PREQESERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433";
    final String SERVERTYPE = "JDBC (JNDI)";
    final String DATABASE_DLL = "crdb_jdbc.dll";
    final String DATABASE = "bssc";
    final String DBCLASSNAME = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    final String USEJDBC = "true";
    final String DATABASE_NAME = "bssc";
    final String SERVERNAME = "jdbc:microsoft:sqlserver://localhost:1433";
    final String CONNECTIONURL = "jdbc:microsoft:sqlserver://localhost:1433";
    final String SERVER = "localhost";
    %>
    <%          
              final Logger logger = Logger.getLogger(ReportAction.class.getName());
              final String REPORT_NAME = "../reports/Krt.rpt";
    try {
              ReportClientDocument oReportClientDocument = new ReportClientDocument();
              oReportClientDocument.open(REPORT_NAME, 0);
         // Create the two connectioninfo objects to use
         IConnectionInfo oldConnectionInfo =  new ConnectionInfo();
         IConnectionInfo newConnectionInfo = new ConnectionInfo();
         // Assign the old Connection info to the reports current info
         DatabaseController dbController = oReportClientDocument.getDatabaseController();
         oldConnectionInfo = dbController.getConnectionInfos(null).getConnectionInfo(0);                                       
         // If this connection needed parameters, we would use this field.      
         Fields pFields = null;
         // Create a new propertybag for the new location
         PropertyBag boPropertyBag1 = new PropertyBag();
         // Set new table logon properties
         boPropertyBag1.put("JDBC Connection String", CONNECTION_STRING);
         boPropertyBag1.put("Trusted_Connection", TRUSTEDCON);
         boPropertyBag1.put("PreQEServerName", PREQESERVERNAME);
         boPropertyBag1.put("Server Type", SERVERTYPE);
         boPropertyBag1.put("Database DLL", DATABASE_DLL);
         boPropertyBag1.put("Database", DATABASE);
         boPropertyBag1.put("Database Class Name", DBCLASSNAME);
         boPropertyBag1.put("Use JDBC", USEJDBC);
         boPropertyBag1.put("Database Name", DATABASE_NAME);
         boPropertyBag1.put("Server Name", SERVERNAME);
         boPropertyBag1.put("Connection URL", CONNECTIONURL);
         boPropertyBag1.put("Server", SERVER);
         // Assign the properties to the connection info
         newConnectionInfo.setAttributes(boPropertyBag1);
         // Set the DB Username and Pwd
         newConnectionInfo.setUserName(DBUSERNAME);
         newConnectionInfo.setPassword(DBPASSWORD);
         // The Kind of connectionInfos is SQL
         newConnectionInfo.setKind(ConnectionInfoKind.SQL);
         // set the parameters to replace.
         // The 4 options are:
         // _doNotVerifyDB
         // _ignoreCurrentTableQualifiers
         // _mapFieldByRowsetPosition
         // _useDefault 
         int replaceParams = DBOptions._ignoreCurrentTableQualifiers + DBOptions._doNotVerifyDB;
         // Now replace the connections      
         dbController.replaceConnection(oldConnectionInfo, newConnectionInfo, pFields, replaceParams);
    %>
    I am not sure why it is not able to get the Driver since the required jar is there in lib folder? Am I missing something ?
    Edited by: sb-onward on Jul 30, 2009 6:01 PM

    Hi,
    Make sure you have set the Classpath in CRConfig.xml for the jdbc jar.
    Place the CrConfig.xml  in the classes directory of your application.
    Please let me know the results.
    Regards,
    Neeraj

  • 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?

  • 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

  • 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

  • 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

  • Load JDBC driver in runtime

    Hi all,
    I'm trying to load mysql jdbc driver in runtime i've tried the following links
    [http://dev-loki.blogspot.com/2008/01/loading-jdbc-driver-at-runtime.html]
    [http://www.kfu.com/~nsayer/Java/dyn-jdbc.html]
    [http://www.devdaily.com/java/edu/JDBC-SQLProcessor/Simple_JDBC_Example.shtml]
    [http://tech.puredanger.com/2006/11/09/classloader/]
    [http://fdt.powerflasher.com/blog/?p=35]
    I'm not being able to get this to work it always given the classnotfoundexception
    can anyone help please?
    Thanks in advance

    There is no server. I'm doing a normal java aplication, i wanted to have a folder where would be the jdbc drivers in runtime the user will choose what driver to load to access a some db.
    I'm using eclipse and this is what i have now
    import java.sql.Connection;
    import java.sql.Driver;
    import java.sql.DriverPropertyInfo;
    import java.sql.SQLException;
    import java.util.Properties;
    public class DriverShim implements Driver{
         private Driver driver;
         public DriverShim(Driver d) {
              this.driver = d;
         public boolean acceptsURL(String u) throws SQLException {
              return this.driver.acceptsURL(u);
         public Connection connect(String u, Properties p) throws SQLException {
              return this.driver.connect(u, p);
         public int getMajorVersion() {
              return this.driver.getMajorVersion();
         public int getMinorVersion() {
              return this.driver.getMinorVersion();
         public DriverPropertyInfo[] getPropertyInfo(String u, Properties p) throws SQLException {
              return this.driver.getPropertyInfo(u, p);
         public boolean jdbcCompliant() {
              return this.driver.jdbcCompliant();
                   String libraryPath = System.getProperty("java.library.path");
              String sep = System.getProperty("path.separator");
              libraryPath = "." + sep + "C:/Users/Luis/Documents/eclipse/workspace/DBDIGGER/lib/connectors" + sep + "native" + sep + libraryPath;
              //libraryPath ="C:/Users/Luis/Documents/eclipse/workspace/DBDIGGER/lib/connectors";
              System.setProperty("java.library.path", libraryPath);
              System.out.println(libraryPath);
    URL u;
              try {
                   u = new URL("jar:file://C:/Users/Luis/Documents/eclipse/workspace/DB/lib/connectors/mysql-connector-java-5.1.7-bin.jar!/");
                   String classname = Settings.MYSQL;
                   URLClassLoader ucl = new URLClassLoader(new URL[] { u });
                   URL[] ee =ucl.getURLs();
                   Driver d = (Driver)Class.forName(classname, true, ucl).newInstance();
                   DriverManager.registerDriver(new DriverShim(d));
                   DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "user", "pw");
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (ClassNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (SQLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (InstantiationException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IllegalAccessException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } Project Folder Structure
    DB
    bin
    lib
    connectors
    mysql-connector-java-5.1.7-bin.jar
    src
    result of classpath
    .;C:/Users/Luis/Documents/eclipse/workspace/DBDIGGER/lib/connectors;native;C:\Program Files\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\Program Files\JavaFX\javafx-sdk1.1\bin;C:\Program Files\JavaFX\javafx-sdk1.1\emulator\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Intel\DMIX;C:\Program Files\Softex\OmniPass;C:\Program Files\MySQL\MySQL Server 5.1\bin
    Maybe what i'm doing wrong is the classpath, this is not a web app is a standard java aplication...
    Could someone explain to me how to set a classpath ?? correctly...

  • ZipException in Loading JDBC Driver

    Getting java.util.zip.ZipException trying to Load JDBC Driver Class.
    The JDBC driver classes are in a jar file which is in WEBLOGIC_CLASSPATH.The
    jar file is perfectly valid, atleast I can see it with "jar".
    It works fine If I extract the jar file into my serverclasses which is in
    WEBLOGIC_CLASSPATH.
    We are running WLS51SP10 on AIX4.3.3. Classic VM (J2RE 1.2.2 IBM build
    ca122-20010313 (JIT enabled: jitc))
    I appreciate any help on this.
    Thanks,
    Pavan
    This is the first few lines from the exception stacktrace.
    java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access$5(ZipFile.java(Compiled Code))
    at
    java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java(Compiled Code))
    at java.util.zip.ZipFile$1.fill(ZipFile.java(Compiled Code))
    at
    java.util.zip.InflaterInputStream.read(InflaterInputStream.java(Compiled
    Code))
    at weblogic.boot.ZipSource.getBytes(ZipSource.java(Compiled Code))
    at
    weblogic.boot.ServerClassLoader.findLocalClass(ServerClassLoader.java(Compil
    ed Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at java.lang.Class.forName1(Native Method)
    at java.lang.Class.forName(Class.java(Compiled Code))
    at common.cimsdao.DaoConnection.getConnection(DaoConnection.java:66)

    Hi.
    You might try getting another copy of the driver. It could be corrupted in some
    way but still work with the jar utility.
    Regards,
    Michael
    Pavan Dinavahi wrote:
    Getting java.util.zip.ZipException trying to Load JDBC Driver Class.
    The JDBC driver classes are in a jar file which is in WEBLOGIC_CLASSPATH.The
    jar file is perfectly valid, atleast I can see it with "jar".
    It works fine If I extract the jar file into my serverclasses which is in
    WEBLOGIC_CLASSPATH.
    We are running WLS51SP10 on AIX4.3.3. Classic VM (J2RE 1.2.2 IBM build
    ca122-20010313 (JIT enabled: jitc))
    I appreciate any help on this.
    Thanks,
    Pavan
    This is the first few lines from the exception stacktrace.
    java.util.zip.ZipException: invalid LOC header (bad signature)
    at java.util.zip.ZipFile.read(Native Method)
    at java.util.zip.ZipFile.access$5(ZipFile.java(Compiled Code))
    at
    java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java(Compiled Code))
    at java.util.zip.ZipFile$1.fill(ZipFile.java(Compiled Code))
    at
    java.util.zip.InflaterInputStream.read(InflaterInputStream.java(Compiled
    Code))
    at weblogic.boot.ZipSource.getBytes(ZipSource.java(Compiled Code))
    at
    weblogic.boot.ServerClassLoader.findLocalClass(ServerClassLoader.java(Compil
    ed Code))
    at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    at java.lang.Class.forName1(Native Method)
    at java.lang.Class.forName(Class.java(Compiled Code))
    at common.cimsdao.DaoConnection.getConnection(DaoConnection.java:66)--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • 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.

  • 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

  • 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

Maybe you are looking for

  • Which one is better ODS-INFOCUBE for reporting in BW

    Hello expert's 1.I want to know which one ODS or INFOCUBES are better (technically/functionally) for reporting  purpose in BW.if some one is having any comparisons on ODS/INFOCUBE then plz pass on to me. 2.Are Z tables reliable in case of data updati

  • Private, or rather non-public, package?

    For better code organization I would like to split a certain package into two packages. One of them, say 'package abcimpl' would contain implementation code that should not have any 'public' accessor declarations. The other, say 'package abc' provide

  • 4.1EA2 - Startup script / serveroutput randomly stops

    I have a startup script that only contains the text "SET SERVEROUTPUT ON".  I've used this flawlessly in previous versions.  In this EA version, it randomly stops displaying the output.  If I quit SQL Developer and restart, it works again.  I haven't

  • The gui status is not working,

    Actually It even does not ask for which screen the status will be created?  I need immediately to solve this problem. Thanks for everyone answering the question. Regards. Deniz

  • Can Internet Explorer sync bookmarks, settings and history just like chrome?

    Google Chrome provides the ability to install their browser and sign into it to retrieve settings, history and bookmarks. As far as an end user experience, this is great. I want to user IE across my work servers, my home servers, desktops and laptops