tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakarta Tomcat Newsgroup (@Basebeans.com) <jakarta-...@basebeans.com>
Subject databases and JNDI resource problem
Date Wed, 01 May 2002 14:40:02 GMT
Subject: databases and JNDI resource problem
From: guido schnider <boulder@gmx.ch>
 ===
While trying to connect a mysql DB with Tomcat 4.0.4-b1 ant struts 1.x 
as described in the Tomcat manual under JNDI Resources HOW-TO
I get the following error. It looks like that he is still looking for 
the HypersonicDriver as in the example, but i changed it.
Any ideas or working examples?
Thanks!

TyrexDataSourceFactory:  Cannot create DataSource, Exception
java.lang.ClassNotFoundException: org.hsql.jdbcDriver

PS: What is the smartest way working with Db's and tomcat/struts?

My configuration
-----------------------------------------------------------------------------
<!-- server.xml  -->
<Resource name="jdbc/test" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/test">
	<parameter>		
		<name>user</name>		
		<value>root</value>		
	</parameter>		
	<parameter>		
		<name>password</name>		
		<value>root</value>		
	</parameter>		
	<parameter>		
		<name>driverClassName</name>
		<value>org.gjt.mm.mysql.Driver</value>		
	</parameter>		
	<parameter>		
		<name>driverName</name>		
		<value>jdbc:mysql:database</value>		
	</parameter>		
</ResourceParams>
-------------------------------------------------------------------------
<!-- Web.xml  -->
<resource-ref>
   <description>
     Resource reference to a factory for java.sql.Connection
     instances that may be used for talking to a particular
     database that is configured in the server.xml file.
   </description>
   <res-ref-name>jdbc/test</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>Container</res-auth>
</resource-ref>
-------------------------------------------------------------------------
//java file
public static final Connection getConnection() throws SQLException {
     try {
         Context env = (Context) new 
InitialContext().lookup("java:comp/env");
         DataSource ds = (DataSource) env.lookup("jdbc/test");
         if (ds==null)
             throw new SQLException("Cannot connect to mysql db test");
         return(ds.getConnection());
     }
     catch (NamingException ne) {
         throw new SQLException(ne.getMessage());
     }
}


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