• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot create JDBC driver of class

 
Roel De Nijs
Sheriff
Posts: 10763
147
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because i got lots of trouble with the configuration of a datasource with struts, i try it now with JNDI

  • part of my server.xml (tomcat 4.29):

  • <!-- Tomcat webGIS Context -->
    <Context path="/webGIS" docBase="webGIS" debug="2"
    reloadable="true" crossContext="true">
    <Logger className="org.apache.catalina.logger.FileLogger"
    prefix="localhost_webgis_log." suffix=".txt"
    timestamp="true"/>

    <Resource name="jdbc/testDB" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/testDB">
    <parameter>
    <name>factory</name>
    <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>driverClassName</name>
    <value>net.sourceforge.jtds.jdbcx.TdsDataSource</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:jtds:sqlserver://AQUASQLW2:1433/AquaGIS</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>gis</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>gis001</value>
    </parameter>
    </ResourceParams>

    </Context>
  • part of my web.xml of my web-app:


  • <resource-ref>
    <description>testing
    </description>
    <res-ref-name>
    jdbc/testDB
    </res-ref-name>
    <res-type>
    javax.sql.DataSource
    </res-type>
    <res-auth>
    Container
    </res-auth>
    </resource-ref>
  • i placed in the %tomcat_home%/common/lib the following jars: jtds-0.8-rc1.jar + commons-dbcp-1.1.jar (like suggested on tomcat homepage)
  • snippet of my code

  • try {
    Context initCtx = new InitialContext();
    Context envCtx = (Context)initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource)envCtx.lookup("jdbc/testDB");
    Connection conn = ds.getConnection();
    System.out.println("DEBUG: " + conn.isClosed());
    conn.close();
    }
    catch (NamingException e) {
    // write to error-log
    }
    catch (SQLException e) {
    // write to error-log
    }

    I get the following error:

    28-07-2004 16:05:47 -- ERROR: Cannot create JDBC driver of class 'net.sourceforge.jtds.jdbcx.TdsDataSource' for connect URL 'jdbc:jtds:sqlserver://AQUASQLW2:1433/AquaGIS'
    28-07-2004 16:05:47 -- 750 in org.apache.commons.dbcp.BasicDataSource.createDataSource (BasicDataSource.java)
    28-07-2004 16:05:47 -- 518 in org.apache.commons.dbcp.BasicDataSource.getConnection (BasicDataSource.java)
    28-07-2004 16:05:47 -- 64 in be.aquafin.webgis.struts.action.KaartActie.zoomIn (KaartActie.java)
    28-07-2004 16:05:47 -- -2 in sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java)
    28-07-2004 16:05:47 -- 39 in sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java)
    28-07-2004 16:05:47 -- 25 in sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java)
    28-07-2004 16:05:47 -- 324 in java.lang.reflect.Method.invoke (Method.java)
    28-07-2004 16:05:47 -- 280 in org.apache.struts.actions.DispatchAction.dispatchMethod (DispatchAction.java)
    28-07-2004 16:05:47 -- 216 in org.apache.struts.actions.DispatchAction.execute (DispatchAction.java)
    28-07-2004 16:05:47 -- 484 in org.apache.struts.action.RequestProcessor.processActionPerform (RequestProcessor.java)
    28-07-2004 16:05:47 -- 274 in org.apache.struts.action.RequestProcessor.process (RequestProcessor.java)
    28-07-2004 16:05:47 -- 1482 in org.apache.struts.action.ActionServlet.process (ActionServlet.java)
    28-07-2004 16:05:47 -- 525 in org.apache.struts.action.ActionServlet.doPost (ActionServlet.java)
    28-07-2004 16:05:47 -- 760 in javax.servlet.http.HttpServlet.service (HttpServlet.java)
    28-07-2004 16:05:47 -- 853 in javax.servlet.http.HttpServlet.service (HttpServlet.java)
    28-07-2004 16:05:47 -- 247 in org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java)
    28-07-2004 16:05:47 -- 193 in org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java)
    28-07-2004 16:05:47 -- 256 in org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java)
    28-07-2004 16:05:47 -- 643 in org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext (StandardPipeline.java)
    28-07-2004 16:05:47 -- 480 in org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java)
    28-07-2004 16:05:47 -- 995 in org.apache.catalina.core.ContainerBase.invoke (ContainerBase.java)
    28-07-2004 16:05:47 -- 191 in org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java)
    28-07-2004 16:05:47 -- 643 in org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext (StandardPipeline.java)
    28-07-2004 16:05:47 -- 480 in org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java)
    28-07-2004 16:05:47 -- 995 in org.apache.catalina.core.ContainerBase.invoke (ContainerBase.java)
    28-07-2004 16:05:47 -- 2417 in org.apache.catalina.core.StandardContext.invoke (StandardContext.java)
    28-07-2004 16:05:47 -- 180 in org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java)
    28-07-2004 16:05:47 -- 643 in org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext (StandardPipeline.java)
    28-07-2004 16:05:47 -- 171 in org.apache.catalina.valves.ErrorDispatcherValve.invoke (ErrorDispatcherValve.java)
    28-07-2004 16:05:47 -- 641 in org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext (StandardPipeline.java)
    28-07-2004 16:05:47 -- 172 in org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java)
    28-07-2004 16:05:47 -- 641 in org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext (StandardPipeline.java)
    28-07-2004 16:05:47 -- 480 in org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java)
    28-07-2004 16:05:47 -- 995 in org.apache.catalina.core.ContainerBase.invoke (ContainerBase.java)
    28-07-2004 16:05:47 -- 174 in org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java)
    28-07-2004 16:05:47 -- 643 in org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext (StandardPipeline.java)
    28-07-2004 16:05:47 -- 480 in org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java)
    28-07-2004 16:05:47 -- 995 in org.apache.catalina.core.ContainerBase.invoke (ContainerBase.java)
    28-07-2004 16:05:47 -- 193 in org.apache.coyote.tomcat4.CoyoteAdapter.service (CoyoteAdapter.java)
    28-07-2004 16:05:47 -- 781 in org.apache.coyote.http11.Http11Processor.process (Http11Processor.java)
    28-07-2004 16:05:47 -- 549 in org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection (Http11Protocol.java)
    28-07-2004 16:05:47 -- 589 in org.apache.tomcat.util.net.TcpWorkerThread.runIt (PoolTcpEndpoint.java)
    28-07-2004 16:05:47 -- 666 in org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run (ThreadPool.java)
    28-07-2004 16:05:47 -- 534 in java.lang.Thread.run (Thread.java)

    Has anyone go a clue how to solve this?

    ps. The url is a correct path to an SQL Server database (is already tested)
     
    prem karun gopal
    Greenhorn
    Posts: 24
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Check whether you have added all required jar/files needed for JDBC in your classpath and all required dlls in your path.
     
    Roel De Nijs
    Sheriff
    Posts: 10763
    147
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks for the suggestion, but i found it myself

    i changed


    into



    and it works fine now.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!