RE: Tomcat Datasource -- please help..

2004-07-27 Thread Shilpa Nalgonda
I have defined the resource in web.xml as below... and also defined the
datasouce resources under context in server.xml... even then it does not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
 Web.xml

web-app
descriptionPrototypeDB Test App/description
 resource-ref
 descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
 res-typejavax.sql.DataSource/res-type
 res-authContainer/res-auth
 /resource-ref
 /web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
Context path=/PrototypeDBTest docBase=PrototypeDBTest
debug=5 reloadable=true crossContext=true
useNaming=true

Logger className=org.apache.catalina.logger.FileLogger
 prefix=localhost_PrototypeDBTest_log. suffix=.txt
 timestamp=true/
 Resource name=jdbc/prototypedb
   auth=Container
   type=javax.sql.DataSource/

ResourceParams name=jdbc/prototypedb
parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter

!-- Maximum number of dB connections in pool. Make sure you
 configure your mysqld max_connections large enough to handle
 all of your db connections. Set to 0 for no limit.
 --
parameter
  namemaxActive/name
  value100/value
/parameter

!-- Maximum number of idle dB connections to retain in pool.
 Set to 0 for no limit.
 --
parameter
 namemaxIdle/name
 value30/value
/parameter

 !-- Maximum time to wait for a dB connection to become
available
 in ms, in this example 10 seconds. An Exception is thrown if
 this timeout is exceeded.  Set to -1 to wait indefinitely.
 --
parameter
 namemaxWait/name
 value1/value
/parameter

!-- MySQL dB username and password for dB connections  --
parameter
  nameusername/name
  valueantonio/value
/parameter
parameter
  namepassword/name
  valueplay/value
/parameter

!-- Class name for mm.mysql JDBC driver --
parameter
  namedriverClassName/name
  valueorg.gjt.mm.mysql.Driver/value
/parameter

!-- The JDBC connection url for connecting to your MySQL dB.
 The autoReconnect=true argument to the url makes sure that the
 mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
 connection.  mysqld by default closes idle connections after 8
hours.
 --
parameter
nameurl/name

valuejdbc:mysql://localhost:3306/prototypedb?autoReconnect=true/value

/parameter
/ResourceParams
/Context


=

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 27, 2004 10:04 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource

In addition to defining the DataSource in Tomcat's admin tool, you'll 
need to define the Resource in you web.xml - something like this:

resource-ref
!-- optional --
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
!-- local JNDI name to use in JSPs, servlets, etc. --
res-ref-name
jdbc/phone
/res-ref-name
res-type
javax.sql.DataSource
/res-type
res-auth
Container
/res-auth
/resource-ref

You'll also need to define a ResourceLink in your Context, that links 
what you want to call your DataSource locally (used in web.xml, see 
above) to what you called your DataSource in the admin tool (globally 
... these can be the same, but don't have to be). Something like this:

  ResourceLink global=jdbc/phone name=jdbc/phone 
type=javax.sql.DataSource/

The 'global' attribute provides the name of the global JNDI resource 
(what was defined in the admin tool); 'name' provides the name of the 
local JNDI resource (what will be referenced in web.xml).

That's it! You shouldn't have any problems once you've done this.

Respectfully,
Brice Ruth



Bussie, Andre D wrote:

I'm using Tomcat 5.0.19. I configured a datasource via the Tomcat Admin
tool to configure a datatsource listed below is the server.xml file
settings for the datasource

GlobalNamingResources

Resource name=jdbc/phone auth=Container
type=javax.sql.DataSource description=Database for the phone
application /

ResourceParams name=jdbc/phone

parameter

namemaxWait/name

   

Re: Tomcat Datasource -- please help..

2004-07-27 Thread Ruth, Brice
I believe if you're defining your DataSource in the Context directly, 
not in the Global Naming Resources, then you do not need the 
resource-ref in web.xml, nor the ResourceLink mentioned below.

What code are you using to get to your connection? The JNDI lookup 
should be to java:comp/env/jdbc/prototypedb, in your particular case.

Respectfully,
Brice Ruth
Shilpa Nalgonda wrote:
I have defined the resource in web.xml as below... and also defined the
datasouce resources under context in server.xml... even then it does not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
Web.xml

web-app
descriptionPrototypeDB Test App/description
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
/web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
Context path=/PrototypeDBTest docBase=PrototypeDBTest
debug=5 reloadable=true crossContext=true
useNaming=true
Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_PrototypeDBTest_log. suffix=.txt
timestamp=true/
Resource name=jdbc/prototypedb
  auth=Container
  type=javax.sql.DataSource/
ResourceParams name=jdbc/prototypedb
parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
--
parameter
 namemaxActive/name
 value100/value
   /parameter
!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
--
   parameter
namemaxIdle/name
value30/value
   /parameter
 !-- Maximum time to wait for a dB connection to become
available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded.  Set to -1 to wait indefinitely.
--
parameter
namemaxWait/name
value1/value
   /parameter
!-- MySQL dB username and password for dB connections  --
parameter
  nameusername/name
  valueantonio/value
/parameter
parameter
  namepassword/name
  valueplay/value
/parameter
!-- Class name for mm.mysql JDBC driver --
parameter
  namedriverClassName/name
  valueorg.gjt.mm.mysql.Driver/value
/parameter
!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
connection.  mysqld by default closes idle connections after 8
hours.
--
parameter
nameurl/name
valuejdbc:mysql://localhost:3306/prototypedb?autoReconnect=true/value
 

/parameter
/ResourceParams
/Context

=
-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 27, 2004 10:04 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource

In addition to defining the DataSource in Tomcat's admin tool, you'll 
need to define the Resource in you web.xml - something like this:

   resource-ref
   !-- optional --
   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
   !-- local JNDI name to use in JSPs, servlets, etc. --
   res-ref-name
   jdbc/phone
   /res-ref-name
   res-type
   javax.sql.DataSource
   /res-type
   res-auth
   Container
   /res-auth
   /resource-ref
You'll also need to define a ResourceLink in your Context, that links 
what you want to call your DataSource locally (used in web.xml, see 
above) to what you called your DataSource in the admin tool (globally 
... these can be the same, but don't have to be). Something like this:

 ResourceLink global=jdbc/phone name=jdbc/phone 
type=javax.sql.DataSource/

The 'global' attribute provides the name of the global JNDI resource 
(what was defined in the admin tool); 'name' provides the name of the 
local JNDI resource (what will be referenced in web.xml).

That's it! You shouldn't have any problems once you've done this.
Respectfully,
Brice Ruth

Bussie, Andre D wrote:
 

I'm using Tomcat 5.0.19. I configured a datasource via the Tomcat Admin
tool to configure a 

RE: Tomcat Datasource -- please help..

2004-07-27 Thread Shilpa Nalgonda
Below is the code i am using to get the connection,
and datasource...
Context ctx = new InitialContext();
Context env = (Context)ctx.lookup(java:comp/env);
DataSource ds = (DataSource) env.lookup(jdbc/prototypedb);
conn = ds.getConnection();

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:07 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..


I believe if you're defining your DataSource in the Context directly, 
not in the Global Naming Resources, then you do not need the 
resource-ref in web.xml, nor the ResourceLink mentioned below.

What code are you using to get to your connection? The JNDI lookup 
should be to java:comp/env/jdbc/prototypedb, in your particular case.

Respectfully,
Brice Ruth

Shilpa Nalgonda wrote:

I have defined the resource in web.xml as below... and also defined the
datasouce resources under context in server.xml... even then it does not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
 Web.xml

web-app
descriptionPrototypeDB Test App/description
 resource-ref
 descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
 res-typejavax.sql.DataSource/res-type
 res-authContainer/res-auth
 /resource-ref
 /web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
   Context path=/PrototypeDBTest docBase=PrototypeDBTest
   debug=5 reloadable=true crossContext=true
useNaming=true

   Logger className=org.apache.catalina.logger.FileLogger
 prefix=localhost_PrototypeDBTest_log. suffix=.txt
 timestamp=true/
 Resource name=jdbc/prototypedb
   auth=Container
   type=javax.sql.DataSource/

   ResourceParams name=jdbc/prototypedb
   parameter
 namefactory/name
 valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
   /parameter

   !-- Maximum number of dB connections in pool. Make sure you
 configure your mysqld max_connections large enough to handle
 all of your db connections. Set to 0 for no limit.
 --
   parameter
  namemaxActive/name
  value100/value
/parameter

   !-- Maximum number of idle dB connections to retain in pool.
 Set to 0 for no limit.
 --
parameter
 namemaxIdle/name
 value30/value
/parameter

!-- Maximum time to wait for a dB connection to become
available
 in ms, in this example 10 seconds. An Exception is thrown if
 this timeout is exceeded.  Set to -1 to wait indefinitely.
 --
   parameter
 namemaxWait/name
 value1/value
/parameter

   !-- MySQL dB username and password for dB connections  --
   parameter
 nameusername/name
 valueantonio/value
   /parameter
   parameter
 namepassword/name
 valueplay/value
   /parameter

   !-- Class name for mm.mysql JDBC driver --
   parameter
 namedriverClassName/name
 valueorg.gjt.mm.mysql.Driver/value
   /parameter

   !-- The JDBC connection url for connecting to your MySQL dB.
 The autoReconnect=true argument to the url makes sure that the
 mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
 connection.  mysqld by default closes idle connections after 8
hours.
 --
   parameter
   nameurl/name

valuejdbc:mysql://localhost:3306/prototypedb?autoReconnect=true/value
  

   /parameter
/ResourceParams
/Context


=

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 27, 2004 10:04 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource

In addition to defining the DataSource in Tomcat's admin tool, you'll 
need to define the Resource in you web.xml - something like this:

resource-ref
!-- optional --
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
!-- local JNDI name to use in JSPs, servlets, etc. --
res-ref-name
jdbc/phone
/res-ref-name
res-type
javax.sql.DataSource
/res-type
res-auth
Container
/res-auth
/resource-ref

You'll also need to define a ResourceLink in your Context, that links 
what you want to call your DataSource locally (used in web.xml, see 
above) to what you called your DataSource

Re: Tomcat Datasource -- please help..

2004-07-27 Thread Ruth, Brice
I believe that should work. I'm out of ideas ... it seems strange that 
the Exception you're getting is complaining about prototypedb not 
being bound, instead of jdbc not being bound ... usually that comes 
first. That's the only thing that sticks out to me, but I don't really 
know what to make of it!

Shilpa Nalgonda wrote:
Below is the code i am using to get the connection,
and datasource...
Context ctx = new InitialContext();
Context env = (Context)ctx.lookup(java:comp/env);
DataSource ds = (DataSource) env.lookup(jdbc/prototypedb);
conn = ds.getConnection();
-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:07 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..
I believe if you're defining your DataSource in the Context directly, 
not in the Global Naming Resources, then you do not need the 
resource-ref in web.xml, nor the ResourceLink mentioned below.

What code are you using to get to your connection? The JNDI lookup 
should be to java:comp/env/jdbc/prototypedb, in your particular case.

Respectfully,
Brice Ruth
Shilpa Nalgonda wrote:
 

I have defined the resource in web.xml as below... and also defined the
datasouce resources under context in server.xml... even then it does not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
Web.xml

web-app
descriptionPrototypeDB Test App/description
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
/web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
Context path=/PrototypeDBTest docBase=PrototypeDBTest
debug=5 reloadable=true crossContext=true
useNaming=true
Logger className=org.apache.catalina.logger.FileLogger
   prefix=localhost_PrototypeDBTest_log. suffix=.txt
   timestamp=true/
   Resource name=jdbc/prototypedb
 auth=Container
 type=javax.sql.DataSource/
ResourceParams name=jdbc/prototypedb
parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
!-- Maximum number of dB connections in pool. Make sure you
   configure your mysqld max_connections large enough to handle
   all of your db connections. Set to 0 for no limit.
   --
parameter
namemaxActive/name
value100/value
  /parameter
!-- Maximum number of idle dB connections to retain in pool.
   Set to 0 for no limit.
   --
  parameter
   namemaxIdle/name
   value30/value
  /parameter
 !-- Maximum time to wait for a dB connection to become
available
   in ms, in this example 10 seconds. An Exception is thrown if
   this timeout is exceeded.  Set to -1 to wait indefinitely.
   --
parameter
   namemaxWait/name
   value1/value
  /parameter
!-- MySQL dB username and password for dB connections  --
parameter
  nameusername/name
  valueantonio/value
/parameter
parameter
  namepassword/name
  valueplay/value
/parameter
!-- Class name for mm.mysql JDBC driver --
parameter
  namedriverClassName/name
  valueorg.gjt.mm.mysql.Driver/value
/parameter
!-- The JDBC connection url for connecting to your MySQL dB.
   The autoReconnect=true argument to the url makes sure that the
   mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
   connection.  mysqld by default closes idle connections after 8
hours.
   --
parameter
nameurl/name
valuejdbc:mysql://localhost:3306/prototypedb?autoReconnect=true/value
/parameter
/ResourceParams
/Context

=
-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 27, 2004 10:04 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource

In addition to defining the DataSource in Tomcat's admin tool, you'll 
need to define the Resource in you web.xml - something like this:

  resource-ref
  !-- optional --
  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
  !-- local JNDI name to use in JSPs, servlets, etc. --
  res-ref-name
  jdbc/phone
  /res-ref-name
  res-type
  javax.sql.DataSource
  /res-type
  res-auth
  Container

RE: Tomcat Datasource -- please help..

2004-07-27 Thread Shilpa Nalgonda
As you have said i am getting jdbc not bound exception only.  But at one
point i changed the env lookup to point to prototypedb instead of
jdbc/prototypedb.. so thats when i get prototypedb not bound error...

Anyway do you think that i have put the context to the jndi resource in the
wrong place in server.xml..
where exactly should i add this in server.xml.

if i add datasource using admin tool the jndi parameter gets added in
GlobalNamingResouce.
which is correct way...

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:29 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..


I believe that should work. I'm out of ideas ... it seems strange that
the Exception you're getting is complaining about prototypedb not
being bound, instead of jdbc not being bound ... usually that comes
first. That's the only thing that sticks out to me, but I don't really
know what to make of it!

Shilpa Nalgonda wrote:

Below is the code i am using to get the connection,
and datasource...
   Context ctx = new InitialContext();
   Context env = (Context)ctx.lookup(java:comp/env);
   DataSource ds = (DataSource) env.lookup(jdbc/prototypedb);
   conn = ds.getConnection();

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:07 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..


I believe if you're defining your DataSource in the Context directly,
not in the Global Naming Resources, then you do not need the
resource-ref in web.xml, nor the ResourceLink mentioned below.

What code are you using to get to your connection? The JNDI lookup
should be to java:comp/env/jdbc/prototypedb, in your particular case.

Respectfully,
Brice Ruth

Shilpa Nalgonda wrote:



I have defined the resource in web.xml as below... and also defined the
datasouce resources under context in server.xml... even then it does not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
Web.xml

web-app
descriptionPrototypeDB Test App/description
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
/web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
  Context path=/PrototypeDBTest docBase=PrototypeDBTest
  debug=5 reloadable=true crossContext=true
useNaming=true

  Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_PrototypeDBTest_log. suffix=.txt
timestamp=true/
Resource name=jdbc/prototypedb
  auth=Container
  type=javax.sql.DataSource/

  ResourceParams name=jdbc/prototypedb
  parameter
namefactory/name
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
  /parameter

  !-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
--
  parameter
 namemaxActive/name
 value100/value
   /parameter

  !-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
--
   parameter
namemaxIdle/name
value30/value
   /parameter

   !-- Maximum time to wait for a dB connection to become
available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded.  Set to -1 to wait indefinitely.
--
  parameter
namemaxWait/name
value1/value
   /parameter

  !-- MySQL dB username and password for dB connections  --
  parameter
nameusername/name
valueantonio/value
  /parameter
  parameter
namepassword/name
valueplay/value
  /parameter

  !-- Class name for mm.mysql JDBC driver --
  parameter
namedriverClassName/name
valueorg.gjt.mm.mysql.Driver/value
  /parameter

  !-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
connection.  mysqld by default closes idle connections after 8
hours.
--
  parameter
  nameurl/name

valuejdbc:mysql://localhost:3306/prototypedb?autoReconnect=true/value


  /parameter
/ResourceParams
/Context


=

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 10:04 AM
To: Tomcat Users List

RE: Tomcat Datasource -- please help..

2004-07-27 Thread Shapira, Yoav

Hola,
Can you use Context#listBindings, iterate through that enumeration, and
print out what bindings you do have in your naming context?

Yoav Shapira
Millennium Research Informatics


-Original Message-
From: Shilpa Nalgonda [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:36 AM
To: Tomcat Users List
Subject: RE: Tomcat Datasource -- please help..

As you have said i am getting jdbc not bound exception only.  But at
one
point i changed the env lookup to point to prototypedb instead of
jdbc/prototypedb.. so thats when i get prototypedb not bound error...

Anyway do you think that i have put the context to the jndi resource in
the
wrong place in server.xml..
where exactly should i add this in server.xml.

if i add datasource using admin tool the jndi parameter gets added in
GlobalNamingResouce.
which is correct way...

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:29 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..


I believe that should work. I'm out of ideas ... it seems strange that
the Exception you're getting is complaining about prototypedb not
being bound, instead of jdbc not being bound ... usually that comes
first. That's the only thing that sticks out to me, but I don't really
know what to make of it!

Shilpa Nalgonda wrote:

Below is the code i am using to get the connection,
and datasource...
  Context ctx = new InitialContext();
  Context env =
(Context)ctx.lookup(java:comp/env);
  DataSource ds = (DataSource)
env.lookup(jdbc/prototypedb);
  conn = ds.getConnection();

-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:07 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..


I believe if you're defining your DataSource in the Context
directly,
not in the Global Naming Resources, then you do not need the
resource-ref in web.xml, nor the ResourceLink mentioned below.

What code are you using to get to your connection? The JNDI lookup
should be to java:comp/env/jdbc/prototypedb, in your particular case.

Respectfully,
Brice Ruth

Shilpa Nalgonda wrote:



I have defined the resource in web.xml as below... and also defined
the
datasouce resources under context in server.xml... even then it does
not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
Web.xml

web-app
descriptionPrototypeDB Test App/description
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
/web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
 Context path=/PrototypeDBTest docBase=PrototypeDBTest
 debug=5 reloadable=true crossContext=true
useNaming=true

 Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_PrototypeDBTest_log. suffix=.txt
timestamp=true/
Resource name=jdbc/prototypedb
  auth=Container
  type=javax.sql.DataSource/

 ResourceParams name=jdbc/prototypedb
 parameter
   namefactory/name

valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
 /parameter

 !-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
--
 parameter
 namemaxActive/name
 value100/value
   /parameter

 !-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
--
   parameter
namemaxIdle/name
value30/value
   /parameter

  !-- Maximum time to wait for a dB connection to become
available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded.  Set to -1 to wait indefinitely.
--
 parameter
namemaxWait/name
value1/value
   /parameter

 !-- MySQL dB username and password for dB connections  --
 parameter
   nameusername/name
   valueantonio/value
 /parameter
 parameter
   namepassword/name
   valueplay/value
 /parameter

 !-- Class name for mm.mysql JDBC driver --
 parameter
   namedriverClassName/name
   valueorg.gjt.mm.mysql.Driver/value
 /parameter

 !-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that
the
mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
connection.  mysqld by default closes idle connections after
8
hours.
--
 parameter

Re: Tomcat Datasource -- please help..

2004-07-27 Thread Ruth, Brice
Well, the way I do it is adding the data source using the admin tool, 
then adding a resource-ref to web.xml and a ResourceLink to the Context. 
This keeps things a bit cleaner in my opinion.

What you're doing should work .. but I can't really give you much more 
than that. Try defining it through the admin tool and following the 
instructions for adding a resource-ref to web.xml and a ResourceLink to 
your Context.

Shilpa Nalgonda wrote:
As you have said i am getting jdbc not bound exception only.  But at one
point i changed the env lookup to point to prototypedb instead of
jdbc/prototypedb.. so thats when i get prototypedb not bound error...
Anyway do you think that i have put the context to the jndi resource in the
wrong place in server.xml..
where exactly should i add this in server.xml.
if i add datasource using admin tool the jndi parameter gets added in
GlobalNamingResouce.
which is correct way...
-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:29 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..
I believe that should work. I'm out of ideas ... it seems strange that
the Exception you're getting is complaining about prototypedb not
being bound, instead of jdbc not being bound ... usually that comes
first. That's the only thing that sticks out to me, but I don't really
know what to make of it!
Shilpa Nalgonda wrote:
 

Below is the code i am using to get the connection,
and datasource...
Context ctx = new InitialContext();
Context env = (Context)ctx.lookup(java:comp/env);
DataSource ds = (DataSource) env.lookup(jdbc/prototypedb);
conn = ds.getConnection();
-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 27, 2004 11:07 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource -- please help..
I believe if you're defining your DataSource in the Context directly,
not in the Global Naming Resources, then you do not need the
resource-ref in web.xml, nor the ResourceLink mentioned below.
What code are you using to get to your connection? The JNDI lookup
should be to java:comp/env/jdbc/prototypedb, in your particular case.
Respectfully,
Brice Ruth
Shilpa Nalgonda wrote:

   

I have defined the resource in web.xml as below... and also defined the
datasouce resources under context in server.xml... even then it does not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
Web.xml

web-app
descriptionPrototypeDB Test App/description
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
/web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
Context path=/PrototypeDBTest docBase=PrototypeDBTest
debug=5 reloadable=true crossContext=true
useNaming=true
Logger className=org.apache.catalina.logger.FileLogger
  prefix=localhost_PrototypeDBTest_log. suffix=.txt
  timestamp=true/
  Resource name=jdbc/prototypedb
auth=Container
type=javax.sql.DataSource/
ResourceParams name=jdbc/prototypedb
parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
!-- Maximum number of dB connections in pool. Make sure you
  configure your mysqld max_connections large enough to handle
  all of your db connections. Set to 0 for no limit.
  --
parameter
   namemaxActive/name
   value100/value
 /parameter
!-- Maximum number of idle dB connections to retain in pool.
  Set to 0 for no limit.
  --
 parameter
  namemaxIdle/name
  value30/value
 /parameter
 !-- Maximum time to wait for a dB connection to become
available
  in ms, in this example 10 seconds. An Exception is thrown if
  this timeout is exceeded.  Set to -1 to wait indefinitely.
  --
parameter
  namemaxWait/name
  value1/value
 /parameter
!-- MySQL dB username and password for dB connections  --
parameter
  nameusername/name
  valueantonio/value
/parameter
parameter
  namepassword/name
  valueplay/value
/parameter
!-- Class name for mm.mysql JDBC driver --
parameter
  namedriverClassName/name
  valueorg.gjt.mm.mysql.Driver/value
/parameter
!-- The JDBC connection url for connecting to your MySQL dB.
  The autoReconnect=true argument to the url makes sure that the
  mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
  connection.  mysqld by default

Re: Tomcat Datasource -- please help..

2004-07-27 Thread David Smith
Hi.  I see a couple of things different from my working setup in your 
setup below.

First: You need a tag as below just before the 
ResourceParams.../ResourceParams block:

Resource name=jdbc/prototypedb  auth=container 
type=javax.sql.DataSource/

Second, and this might not be a show stopper, change the driverClassName 
parameter in your ResourceParams/ResourceParams block to 
com.mysql.jdbc.Driver unless you really are using a version 2 mysql jar 
file.  MySQL/J versions 3.0.x and up switched to com.mysql.jdbc.Driver 
as the primary JDBC driver.

Third, and this isn't in your email, where is your mysql jar file?  
Ideally, it should be in common/lib with the dbcp jar file.  If you've 
changed the location of the mysql jar file, you'll have to restart 
Tomcat.  Otherwise reloading the app will probably be sufficient to make 
the changes live.

--David
Shilpa Nalgonda wrote:
I have defined the resource in web.xml as below... and also defined the
datasouce resources under context in server.xml... even then it does not
help.. I get the same error org.apache.jasper.JasperException: Name
prototypedb is not bound in this Context
Web.xml

web-app
descriptionPrototypeDB Test App/description
resource-ref
descriptionDB Connection/description
res-ref-namejdbc/prototypedb/res-ref-name
res-typejavax.sql.DataSource/res-type
res-authContainer/res-auth
/resource-ref
/web-app
===
server.xml
==
!-- JNDI datasource setup to connect to MYSQL database--
Context path=/PrototypeDBTest docBase=PrototypeDBTest
debug=5 reloadable=true crossContext=true
useNaming=true
Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_PrototypeDBTest_log. suffix=.txt
timestamp=true/
Resource name=jdbc/prototypedb
  auth=Container
  type=javax.sql.DataSource/
ResourceParams name=jdbc/prototypedb
parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
--
parameter
 namemaxActive/name
 value100/value
   /parameter
!-- Maximum number of idle dB connections to retain in pool.
Set to 0 for no limit.
--
   parameter
namemaxIdle/name
value30/value
   /parameter
 !-- Maximum time to wait for a dB connection to become
available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded.  Set to -1 to wait indefinitely.
--
parameter
namemaxWait/name
value1/value
   /parameter
!-- MySQL dB username and password for dB connections  --
parameter
  nameusername/name
  valueantonio/value
/parameter
parameter
  namepassword/name
  valueplay/value
/parameter
!-- Class name for mm.mysql JDBC driver --
parameter
  namedriverClassName/name
  valueorg.gjt.mm.mysql.Driver/value
/parameter
!-- The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld
closed the
connection.  mysqld by default closes idle connections after 8
hours.
--
parameter
nameurl/name
valuejdbc:mysql://localhost:3306/prototypedb?autoReconnect=true/value
 

/parameter
/ResourceParams
/Context

=
-Original Message-
From: Ruth, Brice [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 27, 2004 10:04 AM
To: Tomcat Users List
Subject: Re: Tomcat Datasource

In addition to defining the DataSource in Tomcat's admin tool, you'll 
need to define the Resource in you web.xml - something like this:

   resource-ref
   !-- optional --
   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
   !-- local JNDI name to use in JSPs, servlets, etc. --
   res-ref-name
   jdbc/phone
   /res-ref-name
   res-type
   javax.sql.DataSource
   /res-type
   res-auth
   Container
   /res-auth
   /resource-ref
You'll also need to define a ResourceLink in your Context, that links 
what you want to call your DataSource locally (used in web.xml, see 
above) to what you called your DataSource in the admin tool (globally 
... these can be the same, but don't have to be).