Re: help? JNDI Datasource HOW-TO

2004-02-04 Thread daniel
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" <[EMAIL PROTECTED]>
To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> 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://:3306/javatest?autoReconnect=true,
password=, maxWait=1, 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://:3306/javatest?autoReconnect=true},{type=password,content=
},{type=maxWait,content=1},{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 :::
>
> 
> factory
org.apache.catalina.users.MemoryUserDatabaseFactory
> 
> 
> pathname
> conf/tomcat-users.xml
> 
> 
> 
> 
>  prefix="localhost_DBTest_log." suffix=".txt"
> timestamp="true"/>
>  auth="Container"
> type="javax.sql.DataSource"/>
> 
> 
> factory
org.apache.commons.dbcp.BasicDataSourceFactory
> 
> 
> maxActive
> 100
> 
> 
> maxIdle
> 30
> 
> 
> maxWait
> 1
> 
> 
> username
> Daniel
> 
> 
> password
> 
> 
> 
> driverClassName org.gjt.mm.mysql.Driver
> 
> 
> url
jdbc:mysql://:3306/javatest?autoReconnect=true
> 
> 
> 
> 
> 
> 
> 
>
>
> /DBTest/WEB-INF/web.xml:::
>
> 
>  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd";>
> 
> dbtest
> 
> Welcome to dbtest
> 
> MySQL Test App
> 
> DB Connection
jdbc/TestDB
> javax.sql.DataSource
> Container
> 
> 
>
>
> /DBTest/test.jsp
>
> 
> 
> DB Test
> 
> 
> <%
> foo.DBTest tst = new foo.DBTest();
> tst.init();
> %>
> Results
> Foo <%= tst.getFoo() %>
> Bar <%= tst.getBar() %>
> 
> 
>
>
> /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) {

Re: help? JNDI Datasource HOW-TO

2004-02-03 Thread daniel
oh oops. Thats where i have it otherwise i would never have goten the jsp to
display info.

thanks,
Daniel Schulken
- Original Message - 
From: "Liem Do" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <[EMAIL PROTECTED]>
Sent: Tuesday, February 03, 2004 3:52 PM
Subject: Re: help? JNDI Datasource HOW-TO


> > 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..
> >
> >
> > /DBTest/WEB-INF/foo/DBTest.class
> >
>
> Not sure if this is the problem but your class file should be under:
> /DBTest/WEB-INF/classes/foo/DBTest.class
>
> Everything else looks ok.
>
>
> HTH,
> Liem
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: help? JNDI Datasource HOW-TO

2004-02-03 Thread Liem Do
> 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..
>
>
> /DBTest/WEB-INF/foo/DBTest.class
>

Not sure if this is the problem but your class file should be under:
/DBTest/WEB-INF/classes/foo/DBTest.class

Everything else looks ok.


HTH,
Liem


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



RE: help? JNDI Datasource HOW-TO

2004-02-03 Thread Kumar Abhay-CAK203C
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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
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://:3306/javatest?autoReconnect=true, 
password=, maxWait=1, 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,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql://:3306/javatest?autoReconnect=true},{type=password,content=},{type=maxWait,content=1},{type=maxActive,content=100},{type=driverClassName,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 :::


 
   
factory org.apache.catalina.users.MemoryUserDatabaseFactory


pathname
conf/tomcat-users.xml








factory org.apache.commons.dbcp.BasicDataSourceFactory


maxActive
100


maxIdle
30


maxWait
1


username
Daniel


password



driverClassName org.gjt.mm.mysql.Driver


url 
jdbc:mysql://:3306/javatest?autoReconnect=true









/DBTest/WEB-INF/web.xml:::


http://java.sun.com/dtd/web-app_2_3.dtd";>

dbtest

Welcome to dbtest

MySQL Test App

DB Connection jdbc/TestDB
javax.sql.DataSource
Container




/DBTest/test.jsp



DB Test


<%
foo.DBTest tst = new foo.DBTest();
tst.init();
%>
Results
Foo <%= tst.getFoo() %>
Bar <%= tst.getBar() %>




/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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



help? JNDI Datasource HOW-TO

2004-02-03 Thread daniel
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://:3306/javatest?autoReconnect=true, 
password=, maxWait=1, 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,factoryClassName=org.apache.naming.factory.ResourceFactory,{type=scope,content=Shareable},{type=auth,content=Container},{type=factory,content=org.apache.commons.dbcp.BasicDataSourceFactory},{type=url,content=jdbc:mysql://:3306/javatest?autoReconnect=true},{type=password,content=},{type=maxWait,content=1},{type=maxActive,content=100},{type=driverClassName,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 :::










factory
org.apache.catalina.users.MemoryUserDatabaseFactory


pathname
conf/tomcat-users.xml
















factory
org.apache.commons.dbcp.BasicDataSourceFactory


maxActive
100


maxIdle
30


maxWait
1


username
Daniel


password



driverClassName
org.gjt.mm.mysql.Driver


url
jdbc:mysql://:3306/javatest?autoReconnect=true









/DBTest/WEB-INF/web.xml:::


http://java.sun.com/dtd/web-app_2_3.dtd";>

dbtest

Welcome to dbtest

MySQL Test App

DB Connection
jdbc/TestDB
javax.sql.DataSource
Container




/DBTest/test.jsp



DB Test


<%
foo.DBTest tst = new foo.DBTest();
tst.init();
%>
Results
Foo <%= tst.getFoo() %>
Bar <%= tst.getBar() %>




/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