I had your same problem. I couldn't find any solution but I solved the
problem in this way:

I have set the URL string and the driver name in server.xml as Strings:

<Environment name="ISAS_CS"
    type="java.lang.String"
    value="jdbc:..." />

<Environment name="ISAS_DN" type="java.lang.String"
    value="com.informix.jdbc.IfxDriver" />

and then I use JNDI lookups for them and I create a connection with:

        Class.forName(driverName);
        conn=DriverManager.getConnection(connectionString);

-- Ivan

-----Messaggio originale-----
Da: Andy Grove [mailto:[EMAIL PROTECTED]
Inviato: luned́ 5 aprile 2004 12.03
A: [EMAIL PROTECTED]
Oggetto: Cannot create JDBC driver of class '' for connect URL 'null'


Hi,

I am trying to convert my Tomcat web application to use JNDI to lookup a
DataSource rather than using DriverManager directly. My application
works fine using DriverManager so I know I have my classpath set up
correctly.

The problem I have seems to be a very common one yet I cannot find a
solution to it using Google. I am getting the following error message
when I attempt to look up a DataSource:

Cannot create JDBC driver of class '' for connect URL 'null'

This implies to me that Tomcat is recognizing my <Resource> declaration
in my conf/server.xml but is not loading the associated
<ResourceParams>. I get this problem with Tomcat 4.1 and 5.0 on Red Hat
9 with Sun JDK 1.4.2.

My web.xml contains:

  <resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/mydb</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

My $TOMCAT_HOME/conf/server.xml contains the following (I have tried
defining this within the context of my webapp and also in the
GlobalNamingResources section).

 <Resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"
/>

<ResourceParams name="jdbc/mydb">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>maxActive</name>
      <value>100</value>
    </parameter>
    <parameter>
      <name>maxIdle</name>
      <value>30</value>
    </parameter>
    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>
    <parameter>
     <name>username</name>
     <value>ebay</value>
    </parameter>
    <parameter>
     <name>password</name>
     <value></value>
    </parameter>
    <parameter>
       <name>driverClassName</name>
       <value>org.postgresql.Driver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:postgresql://localhost/mydb</value>
    </parameter>
  </ResourceParams>

Lastly, my Java code is as follows:

InitialContext initCtx = new InitialContext();
Object obj = initCtx.lookup( "java:comp/env/jdbc/mydb" );
DataSource ds = (DataSource) obj;
return ds.getConnection();

Does anyone have JNDI working with Tomcat? Any help would be much
appreciated!

Thanks,

Andy Grove.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to