tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Diego Castillo" <diego.casti...@inexbee.com>
Subject MySQL DataSource using Tomcat 4
Date Fri, 14 Dec 2001 09:18:58 GMT
Hi all!

I have a JSP that must fetch some information from a MySQL database.
Everything works fine if I create manually a DataSource in my code:

  org.gjt.mm.mysql.MysqlDataSource pool =
    new org.gjt.mm.mysql.MysqlDataSource();
  pool.setServerName("localhost");
  pool.setPort(3306);
  pool.setDatabaseName("pim");


Now I would like Tomcat to create this DataSource object at start-up and
find it using JNDI ENC. My code looks like:

  InitialContext initialContext = new InitialContext();
  DataSource pool =
    (DataSource) initialContext.lookup("java:comp/env/jdbc/pim");


This code does find a DataSource object, but it seems that the object found
is not initialised. I have tried many different combinations for my
"server.xml" file, but it just looks impossible to figure out what the
problem is. The JDBC driver is below common/lib and I am using Tomcat in
standalone mode. My "server.xml" file looks like:

  <Context path="" docBase="pim" debug="0">
    <Resource name="jdbc/pim" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/pim">
      <parameter>
        <name>driverClassName</name>
        <value>org.gjt.mm.mysql.MysqlDataSource</value>
      </parameter>
      <parameter>
        <name>driverName</name>
        <value>jdbc:mysql://localhost:3306/pim</value>
      </parameter>
    </ResourceParams>
  </Context>


Does anybody know what is happening? How do I instruct tyrex about the
factory it should use?


Any help would be welcome!


Diego Castillo


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