Hi,

I suspect that the driverName value ("jdbc:mysql:@qhds0004:3306:qRoom") has
a valid syntax in your server.xml file. The format should be in
jdbc:mysql://<host>:<port>/<db> form.

Also instead of

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

try

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

For more information check out JNDI Resources HOW-TO.


Ozgur.




>-----Original Message-----
>From: Frank Marx [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, April 02, 2002 1:37 AM
>To: Tomcat Users List
>Subject: Problems with JDBC-Datasource as Resource in JNDI
>
>
>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:[EMAIL PROTECTED]>
>For additional commands: <mailto:[EMAIL PROTECTED]>
>Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>



--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to