tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <dan...@etrak-plus.com>
Subject Re: help? JNDI Datasource HOW-TO
Date Wed, 04 Feb 2004 13:29:13 GMT
I found out that the mysql-connector-java-3.0.10-stable-bin.jar needs to be
in the \common\lib directory.
that was all that i over looked :(

thanks eveybody

----- Original Message ----- 
From: "Kumar Abhay-CAK203C" <CAK203C@motorola.com>
To: "'Tomcat Users List'" <tomcat-user@jakarta.apache.org>
Sent: Tuesday, February 03, 2004 3:21 PM
Subject: RE: help? JNDI Datasource HOW-TO


> Hello,
>
> I am having the same problem since last 3 days and no final solution yet I
hv posted the msg 2 time to this gr but all in vain
> Pls share it with me if u hv any solution..
>
> Abhay
>
>
> -----Original Message-----
> From: daniel@etrak-plus.com [mailto:daniel@etrak-plus.com]
> Sent: Tuesday, February 03, 2004 1:48 PM
> To: Tomcat Users List
> Subject: help? JNDI Datasource HOW-TO
>
>
> i have followed the example but changed the location of the database to
another machine. Tomcat 5.0.18
>
> the test.jsp returns
>
> Results
> Foo Not Connected
> Bar -1
>
> checking the DBTest log i get :
>
>
> 2004-02-03 14:19:36 NamingContextListener[/Catalina/localhost/DBTest]:
Resource parameters for jdbc/TestDB = ResourceParams[name=jdbc/TestDB,
parameters={factory=org.apache.commons.dbcp.BasicDataSourceFactory,
url=jdbc:mysql://<internal ip address>:3306/javatest?autoReconnect=true,
password=<password>, maxWait=10000, maxActive=100,
driverClassName=org.gjt.mm.mysql.Driver, username=Daniel, maxIdle=30}]
> 2004-02-03 14:19:36 NamingContextListener[/Catalina/localhost/DBTest]:
Adding resource ref jdbc/TestDB
> 2004-02-03 14:19:36 NamingContextListener[/Catalina/localhost/DBTest]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factory
ClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shar
eable},{type=auth,content=Container},{type=factory,content=org.apache.common
s.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql://<internal ip
address>:3306/javatest?autoReconnect=true},{type=password,content=<password>
},{type=maxWait,content=10000},{type=maxActive,content=100},{type=driverClas
sName,content=org.gjt.mm.mysql.Driver},{type=username,content=Daniel},{type=
maxIdle,content=30}]
> 2004-02-03 14:19:36 NamingContextListener[/Catalina/localhost/DBTest]:
Resource parameters for UserTransaction = null
>
> at this point im stumped.
>
> server.xml is :::
>
> <Server port="8005" shutdown="SHUTDOWN" debug="0">
> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/> <Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/> <GlobalNamingResources> <Environment name="simpleValue"
type="java.lang.Integer" value="30"/> <Resource name="UserDatabase"
auth="Container" type="org.apache.catalina.UserDatabase" description="User
database that can be updated and saved"> </Resource> <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>
> </GlobalNamingResources>
> <Service name="Catalina">
> <Connector port="8080" maxThreads="150" minSpareThreads="25"
maxSpareThreads="75" enableLookups="false" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
disableUploadTimeout="true"/> <Connector port="8009" enableLookups="false"
redirectPort="8443" debug="0" protocol="AJP/1.3"/> <Engine name="Catalina"
defaultHost="localhost" debug="0"> <Logger
className="org.apache.catalina.logger.FileLogger" prefix="catalina_log."
suffix=".txt" timestamp="true"/> <Realm
className="org.apache.catalina.realm.UserDatabaseRealm" debug="0"
resourceName="UserDatabase"/> <Host name="localhost" debug="0"
appBase="webapps" unpackWARs="true" autoDeploy="true"> <Logger
className="org.apache.catalina.logger.FileLogger" directory="logs"
prefix="localhost_log." suffix=".txt" timestamp="true"/> <Context
path="/DBTest" docBase="DBTest" debug="5" reloadable="true"
crossContext="true"> <Logger
className="org.apache.catalina.logger.FileLogger"
> prefix="localhost_DBTest_log." suffix=".txt"
> timestamp="true"/>
> <Resource name="jdbc/TestDB"
> auth="Container"
> type="javax.sql.DataSource"/>
> <ResourceParams name="jdbc/TestDB">
> <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>Daniel</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value><password></value>
> </parameter>
> <parameter>
> <name>driverClassName</name> <value>org.gjt.mm.mysql.Driver</value>
> </parameter>
> <parameter>
> <name>url</name>
<value>jdbc:mysql://<ipaddress>:3306/javatest?autoReconnect=true</value>
> </parameter>
> </ResourceParams>
> </Context>
> </Host>
> </Engine>
> </Service>
> </Server>
>
>
> /DBTest/WEB-INF/web.xml:::
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
> <display-name>dbtest</display-name>
> <description>
> Welcome to dbtest
> </description>
> <description>MySQL Test App</description>
> <resource-ref>
> <description>DB Connection</description>
<res-ref-name>jdbc/TestDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
> </web-app>
>
>
> /DBTest/test.jsp
>
> <html>
> <head>
> <title>DB Test</title>
> </head>
> <body>
> <%
> foo.DBTest tst = new foo.DBTest();
> tst.init();
> %>
> <h2>Results</h2>
> Foo <%= tst.getFoo() %><br/>
> Bar <%= tst.getBar() %>
> </body>
> </html>
>
>
> /DBTest/WEB-INF/foo/DBTest.class
>
> package foo;
>
> import javax.naming.*;
> import javax.sql.*;
> import java.sql.*;
>
> public class DBTest {
>
>   String foo = "Not Connected";
>   int bar = -1;
>
>   public void init() {
>     try{
>       Context ctx = new InitialContext();
>       if(ctx == null )
>           throw new Exception("Boom - No Context");
>
>       DataSource ds =
>             (DataSource)ctx.lookup(
>                "java:comp/env/jdbc/TestDB");
>
>       if (ds != null) {
>         Connection conn = ds.getConnection();
>
>         if(conn != null)  {
>             foo = "Got Connection "+conn.toString();
>             Statement stmt = conn.createStatement();
>             ResultSet rst =
>                 stmt.executeQuery(
>                   "select id, foo, bar from testdata");
>             if(rst.next()) {
>                foo=rst.getString(2);
>                bar=rst.getInt(3);
>             }
>             conn.close();
>         }
>       }
>     }catch(Exception e) {
>       e.printStackTrace();
>     }
>  }
>
>  public String getFoo() { return foo; }
>  public int getBar() { return bar;}
> }
> What am i missing?thanks,Daniel Schulken---Outgoing mail is certified
Virus Free.Checked by AVG anti-virus system
(http://www.grisoft.com).Version: 6.0.576 / Virus Database: 365 - Release
Date: 1/30/2004
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.576 / Virus Database: 365 - Release Date: 1/30/2004


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