tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank Marx" <frank.m...@quipus.de>
Subject Problems with JDBC-Datasource as Resource in JNDI
Date Tue, 02 Apr 2002 09:37:28 GMT
Hi,

I defined a mysql-Datasource as a resource in JNDI.
I can lookup the datasource but everytime when I call the Datasour -
getConnection Method 
the error message "no suitable driver" shows up.

Here are my configuration files:

WEB.XML: (only resource part)

  <resource-ref>
    <description>

    test

  </description>

  <res-ref-name>jdbc/MySQLDB</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
   <res-auth />
  </resource-ref>

 </web-app>

SERVER.XML:

   <Context path="" docBase="C:\struts_forte" debug="0">
          <Valve
className="org.netbeans.modules.web.monitor.catalina.MonitorValve" />
          <Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost__log."        suffix=".txt" timestamp="true" />
	  <Resource name="jdbc/MySQLDB" auth="Container"
type="javax.sql.DataSource"/>
	  <ResourceParams name="jdbc/MySQLDB">

    	<parameter>

        <name>user</name>

         <value>quipi</value>

    </parameter>

    <parameter>

      <name>password</name>

      <value>devel</value>

    </parameter>

    <parameter>

      <name>driverClassName</name>

      <value>org.gjt.mm.mysql.Driver</value>

    </parameter>

    <parameter>

      <name>driverName</name>

      <value>jdbc:mysql:@qhds0004:3306:qRoom</value>

    </parameter>
      </ResourceParams>
	</Context>

The JAVA - Code which tries to create the connection from the
datasource:

      InitialContext ic = new InitialContext();
    
      DataSource ds =
(DataSource)ic.lookup("java:comp/env/jdbc/MySQLDB");

     

      System.out.println("TEST:" + ic.INITIAL_CONTEXT_FACTORY);
     
	// When I comment the following line of code out I don't get the
exception but also
	// no connection :-(	
      Connection con = ds.getConnection();
      
      } catch(javax.naming.NamingException ex) {
            ex.printStackTrace();
      }
      catch(java.sql.SQLException ex) {
            System.out.println(ex.getSQLState());
            ex.printStackTrace();
      }


The mysql-jar is in the lib directory of the web - application and also
lib - directory of my TOMCAT installation which is version 4.01.

Any suggestions how to solve the problem ? Is the URL to the my-sql
database ok or do I need to copy the mysql-drivers somewhere ?

Thanks in advance,

Frank Marx

--
To unsubscribe:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands: <mailto:tomcat-user-help@jakarta.apache.org>
Troubles with the list: <mailto:tomcat-user-owner@jakarta.apache.org>


Mime
View raw message