tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niraj Alok" <ni...@emacmillan.com>
Subject configure data source
Date Sat, 17 Apr 2004 00:04:15 GMT

 Hi All,


 I am trying to obtain a connection using DataSource
 in Tomcat5 .

 I get the following error :

 org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
 class '' for connect URL 'null', cause:

 java.sql.SQLException: No suitable driver



 My source code is :

     Context ctx = new InitialContext();

     if (ctx == null)

         throw new Exception("No context got! Exception");

     System.out.println("got ctx");

     DataSource ds =

         (DataSource) ctx.lookup("java:comp/env/jdbc/hypersonic");


     if(ds == null)

         throw new Exception("No ds got! Exception");

     else

     {

     System.out.println("got ds");

     Connection con = ds.getConnection();

     if(con != null)

      ....
      ...
     }


 My server.xml looks like :

<GlobalNamingResources>

<Environment name="simpleValue" type="java.lang.Integer" value="30"/>

<Resource auth="Container" description="User database that can be updated
and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>

<Resource name="hypersonic" type="javax.sql.DataSource"/>

<ResourceParams name="UserDatabase">

<parameter>

<name>factory</name>

<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>

</parameter>

<parameter>

<name>pathname</name>

<value>conf/tomcat-users.xml</value>

</parameter>

</ResourceParams>

<ResourceParams name="hypersonic">

<parameter>

<name>maxWait</name>

<value>5000</value>

</parameter>

<parameter>

<name>maxActive</name>

<value>20</value>

</parameter>

<parameter>

<name>password</name>

<value></value>

</parameter>

<parameter>

<name>url</name>

<value>jdbc:hsqldb:hsql://localhost:1701</value>

</parameter>

<parameter>

<name>driverClassName</name>

<value>org.hsqldb.jdbcDriver</value>

</parameter>

<parameter>

<name>maxIdle</name>

<value>2</value>

</parameter>

<parameter>

<name>username</name>

<value>sa</value>

</parameter>

</ResourceParams>

</GlobalNamingResources>



   My web.xml contains:



   <resource-ref>

   <description>DB Connection</description>

   <res-ref-name>jdbc/hypersonic</res-ref-name>

   <res-type>javax.sql.DataSource</res-type>

   <res-auth>Container</res-auth>

   </resource-ref>



   Even if i comment this entry in web.xml the error is still the same.



   Can any one please tell me what am I doing wrong??

   Regards,
   Niraj




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message