Aliases for JNDI (JDBC) resources?

2005-10-03 Thread Lisa L. Woodring
I would like to create aliases for a JNDI (specifically, a JDBC)
resource, such that I can use multiple names to connect to the same
database -- and be able to use the same (i.e. only 1) connection pool
for that database.  I haven't been able to find anything on how/if this
is possible.  (I would like to be able to specify it all in context.xml
 not touch server.xml if possible.)  Any suggestions??

In other words, be able to do something to this effect (in context.xml):

Resource name=jdbc/actual_db_name auth=Container
type=javax.sql.DataSource
  driverClassName=org.postgresq.Driver   
  url=jdbc:postgresql://machine/actual_db_name
  maxActive=100 maxIdle=5  ...other parms...  /

alias link=jdbc/alias1 resource=jdbc/actual_db_name /
alias link=jdbc/alias2 resource=jdbc/actual_db_name /

Then use the jdbc/alias1 and jdbc/alias2 names in my code.


Lisa Woodring
Software Engineer, iGLASS Networks





Re: Aliases for JNDI (JDBC) resources?

2005-10-03 Thread David Smith
To be honest, I think touching the server.xml is the only way to do
this.  Declare it as a global resource in server.xml and then declare a
resource link in all the contexts that need access.

--David

Lisa L. Woodring wrote:

I would like to create aliases for a JNDI (specifically, a JDBC)
resource, such that I can use multiple names to connect to the same
database -- and be able to use the same (i.e. only 1) connection pool
for that database.  I haven't been able to find anything on how/if this
is possible.  (I would like to be able to specify it all in context.xml
 not touch server.xml if possible.)  Any suggestions??

In other words, be able to do something to this effect (in context.xml):

Resource name=jdbc/actual_db_name auth=Container
type=javax.sql.DataSource
  driverClassName=org.postgresq.Driver   
  url=jdbc:postgresql://machine/actual_db_name
  maxActive=100 maxIdle=5  ...other parms...  /

alias link=jdbc/alias1 resource=jdbc/actual_db_name /
alias link=jdbc/alias2 resource=jdbc/actual_db_name /

Then use the jdbc/alias1 and jdbc/alias2 names in my code.


Lisa Woodring
Software Engineer, iGLASS Networks




  



-- 
===
David Smith
Network Operations Supervisor
Department of Entomology
College of Agriculture  Life Sciences
Cornell University
2132 Comstock Hall
Ithaca, NY  14853
Phone: 607.255.9571
Fax: 607.255.0939


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



Re: JNDI jdbc resources

2003-01-28 Thread Paul Carpenter
Interesting. I'll have a play.

But that url string works with DBVisualizer (which is also jdbc based).  
So maybe not, as I think this is correct for SYbase (I get the same  
problem with mySql, even vut'n'paste examples give the same problem ?

The db driver (jconn2.jar) is in common/lib - which I believe is right.

I'm starting to think that this just plain doesn't work in Tomcat (at  
least not in 4.1.12 or 18) - I've tried both now. Unless MAC OSX is to  
blame?


Paul


On Tuesday, January 28, 2003, at 12:06  PM, Peng Tuck Kwok wrote:

Hmm, Paul your url(in server.xml) looks a bit weird to me. Sure it is  
correct ?
I have mind written of the form
 parameter
  nameurl/name
  valuejdbc:sapdb://[url or ip]/[db name]/value
  /parameter

instead of  
valuejdbc:sybase:Tds:PowerBookPaul:11222/multiLeague/value

What's the Tds and don't we need the // before the machine name ?
If you are sure that this is correct then don't worry about what I  
just wrote. Just something you can double check. Also where did you  
put the db driver?

Paul Carpenter wrote:
Hi Peng
For Shawn's benefit - the context you see is in my server.xml (well,   
actually, a separate xml file just like the manager.xml and admin.xml  
 in the /webapps directory).
Based on the other posting to the list, I've tried both with the   
web.xml file having nothing for the resource defined, and also as  
below  (after the servlet mappings):
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/DBmultileague
/res-ref-name
  res-type
javax.sql.DataSource
  /res-type
  res-auth
Container
  /res-auth
/resource-ref
Thanks
Paul
On Monday, January 27, 2003, at 09:21  AM, Peng Tuck Kwok wrote:
Let's have a look at your web.xml as well. Might be helpful.

Paul Carpenter wrote:


Hi All
I've scoured the list and got so close, yet so far from making the   
jdbc  stuff work. With some help from Manav and other postings,  
this  is what  i see. can anyone solve the riddle?
Please see the cut'n'pastes below. I draw you attention to the fact  
  that the connection looks good right up to the point where it's  
used  -  like the DataSource object is good (because ds != null  
is true),  yet  the getConnection method throws the often seen  
Cannot load JDBC  driver  class 'null' error.
I know this is very close...what's missing?
I'm sure my jars are in the right place, as a regular forClass   
approach  in the same webapp works with no problems?
Thanks
Paul
tomcat 4.1.12, Mac OSX 10.2.3
Output from my test servlet:
Simple lookup test :
dbName : org.apache.commons.dbcp.BasicDataSource@25debb
list() on /comp/env Context :
Binding : jdbc: org.apache.naming.NamingContext
listBindings() on /comp/env Context :
Binding : jdbc:
org.apache.naming.NamingContext:org.apache.naming.NamingContext@41f8 
0c
list() on full Context :
Binding : DBmultileague: org.apache.commons.dbcp.BasicDataSource
listBindings() on full Context today:
Binding : DBmultileague:
org.apache.commons.dbcp.BasicDataSource:org.apache.commons.dbcp.Basi 
cD at aSource@25debb
Connecting1 : Connecting2 : Connecting3 : Query1 :
The relevant servlet code;
try {
out.println(list() on full Context : );
NamingEnumeration enum2 =   
ctx.list(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
out.println(listBindings() on full Context today: );
enum2 = ctx.listBindings(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
} catch (NamingException e) {
out.println(JNDI lookup failed :  + e);
}
try{
Context ctx2 = new InitialContext();
out.print(Connecting1 : );
 Context envCtx2 = (Context)
ctx2.lookup(java:/comp/env/);
out.print(Connecting2 : );
 DataSource ds = (DataSource)
envCtx2.lookup(jdbc/DBmultileague);
out.print(Connecting3 : );
  if (ds != null) {
out.print(Query1 : );
Connection conn = ds.getConnection();
out.print(Query2 : );
The context/resource definition:
Context path=/DBmultileague-0.1-dev   
docBase=DBmultileague-0.1-dev  debug=5 reloadable=true
naming=true crossContext=true
   Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_DBmultileague_log. suffix=.txt
timestamp=true/
   Resource 

Re: JNDI jdbc resources

2003-01-27 Thread Paul Carpenter
Hi Peng

For Shawn's benefit - the context you see is in my server.xml (well,  
actually, a separate xml file just like the manager.xml and admin.xml  
in the /webapps directory).

Based on the other posting to the list, I've tried both with the  
web.xml file having nothing for the resource defined, and also as below  
(after the servlet mappings):

	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/DBmultileague
		/res-ref-name
  		res-type
		javax.sql.DataSource
  		/res-type
  		res-auth
			Container
  		/res-auth
	/resource-ref



Thanks
Paul

On Monday, January 27, 2003, at 09:21  AM, Peng Tuck Kwok wrote:

Let's have a look at your web.xml as well. Might be helpful.

Paul Carpenter wrote:

Hi All
I've scoured the list and got so close, yet so far from making the  
jdbc  stuff work. With some help from Manav and other postings, this  
is what  i see. can anyone solve the riddle?
Please see the cut'n'pastes below. I draw you attention to the fact   
that the connection looks good right up to the point where it's used  
-  like the DataSource object is good (because ds != null is true),  
yet  the getConnection method throws the often seen Cannot load JDBC  
driver  class 'null' error.
I know this is very close...what's missing?
I'm sure my jars are in the right place, as a regular forClass  
approach  in the same webapp works with no problems?
Thanks
Paul
tomcat 4.1.12, Mac OSX 10.2.3
Output from my test servlet:
Simple lookup test :
dbName : org.apache.commons.dbcp.BasicDataSource@25debb
list() on /comp/env Context :
Binding : jdbc: org.apache.naming.NamingContext
listBindings() on /comp/env Context :
Binding : jdbc:   
org.apache.naming.NamingContext:org.apache.naming.NamingContext@41f80c
list() on full Context :
Binding : DBmultileague: org.apache.commons.dbcp.BasicDataSource
listBindings() on full Context today:
Binding : DBmultileague:   
org.apache.commons.dbcp.BasicDataSource:org.apache.commons.dbcp.BasicD 
at aSource@25debb
Connecting1 : Connecting2 : Connecting3 : Query1 :
The relevant servlet code;
try {
out.println(list() on full Context : );
NamingEnumeration enum2 =  
ctx.list(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
out.println(listBindings() on full Context today: );
enum2 = ctx.listBindings(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
} catch (NamingException e) {
out.println(JNDI lookup failed :  + e);
}
try{
Context ctx2 = new InitialContext();
out.print(Connecting1 : );
 Context envCtx2 = (Context)   
ctx2.lookup(java:/comp/env/);
out.print(Connecting2 : );
 DataSource ds = (DataSource)   
envCtx2.lookup(jdbc/DBmultileague);
out.print(Connecting3 : );
  if (ds != null) {
out.print(Query1 : );
Connection conn = ds.getConnection();
out.print(Query2 : );
The context/resource definition:
Context path=/DBmultileague-0.1-dev  
docBase=DBmultileague-0.1-dev  debug=5 reloadable=true   
naming=true crossContext=true
   Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_DBmultileague_log. suffix=.txt   
timestamp=true/
   Resource name=jdbc/DBmultileague  
auth=Container  type=javax.sql.DataSource/
ResourceParams name=jdbc/DBmultileague
ParameternamemaxIdle/namevalue3000/value/Parameter
ParameternamemaxActive/namevalue10/value/Parameter
ParameternamemaxWait/namevalue10/value/Parameter
Parameternameusername/namevaluesa/value/Parameter
Parameternamepassword/namevalue/value/Parameter
Parameter
namefactory/name
 
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/Parameter
  Parameter
namedriverClassName/name
valuecom.sybase.jdbc2.jdbc.SybDriver/value
/Parameter
Parameter
nameurl/name
 
valuejdbc:sybase:Tds:PowerBookPaul:11222/multiLeague/value
/Parameter
 
ParameternameinitialPoolSize/namevalue2/value/Parameter
/ResourceParams



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



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




Re: JNDI jdbc resources

2003-01-27 Thread shawn
Hey catv... used to use them

just to confirm,

this is not your server.xml
Resource name=jdbc/myoracle auth=Container
 type=javax.sql.DataSource/
   
   

that I beleive was an earlier post and different from

jdbc/DBmultileague

anyway, I had a similar prob and it was in my server.xml  that's why I
suggested it.

yours may be different

shawn

On Mon, 2003-01-27 at 19:45, Paul Carpenter wrote:
 Hi Peng
 
 For Shawn's benefit - the context you see is in my server.xml (well,  
 actually, a separate xml file just like the manager.xml and admin.xml  
 in the /webapps directory).
 
 Based on the other posting to the list, I've tried both with the  
 web.xml file having nothing for the resource defined, and also as below  
 (after the servlet mappings):
 
   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/DBmultileague
   /res-ref-name
   res-type
   javax.sql.DataSource
   /res-type
   res-auth
   Container
   /res-auth
   /resource-ref
-- 
shawn [EMAIL PROTECTED]


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




Re: JNDI jdbc resources

2003-01-27 Thread Peng Tuck Kwok
Hmm, Paul your url(in server.xml) looks a bit weird to me. Sure it is 
correct ?
I have mind written of the form
 parameter
  nameurl/name
  valuejdbc:sapdb://[url or ip]/[db name]/value
  /parameter

instead of valuejdbc:sybase:Tds:PowerBookPaul:11222/multiLeague/value

What's the Tds and don't we need the // before the machine name ?
If you are sure that this is correct then don't worry about what I just 
wrote. Just something you can double check. Also where did you put the 
db driver?

Paul Carpenter wrote:
Hi Peng

For Shawn's benefit - the context you see is in my server.xml (well,  
actually, a separate xml file just like the manager.xml and admin.xml  
in the /webapps directory).

Based on the other posting to the list, I've tried both with the  
web.xml file having nothing for the resource defined, and also as below  
(after the servlet mappings):

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/DBmultileague
/res-ref-name
  res-type
javax.sql.DataSource
  /res-type
  res-auth
Container
  /res-auth
/resource-ref



Thanks
Paul

On Monday, January 27, 2003, at 09:21  AM, Peng Tuck Kwok wrote:

Let's have a look at your web.xml as well. Might be helpful.

Paul Carpenter wrote:


Hi All
I've scoured the list and got so close, yet so far from making the  
jdbc  stuff work. With some help from Manav and other postings, this  
is what  i see. can anyone solve the riddle?
Please see the cut'n'pastes below. I draw you attention to the fact   
that the connection looks good right up to the point where it's used  
-  like the DataSource object is good (because ds != null is 
true),  yet  the getConnection method throws the often seen Cannot 
load JDBC  driver  class 'null' error.
I know this is very close...what's missing?
I'm sure my jars are in the right place, as a regular forClass  
approach  in the same webapp works with no problems?
Thanks
Paul
tomcat 4.1.12, Mac OSX 10.2.3
Output from my test servlet:
Simple lookup test :
dbName : org.apache.commons.dbcp.BasicDataSource@25debb
list() on /comp/env Context :
Binding : jdbc: org.apache.naming.NamingContext
listBindings() on /comp/env Context :
Binding : jdbc:   
org.apache.naming.NamingContext:org.apache.naming.NamingContext@41f80c
list() on full Context :
Binding : DBmultileague: org.apache.commons.dbcp.BasicDataSource
listBindings() on full Context today:
Binding : DBmultileague:   
org.apache.commons.dbcp.BasicDataSource:org.apache.commons.dbcp.BasicD 
at aSource@25debb
Connecting1 : Connecting2 : Connecting3 : Query1 :
The relevant servlet code;
try {
out.println(list() on full Context : );
NamingEnumeration enum2 =  ctx.list(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
out.println(listBindings() on full Context today: );
enum2 = ctx.listBindings(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
} catch (NamingException e) {
out.println(JNDI lookup failed :  + e);
}
try{
Context ctx2 = new InitialContext();
out.print(Connecting1 : );
 Context envCtx2 = (Context)   
ctx2.lookup(java:/comp/env/);
out.print(Connecting2 : );
 DataSource ds = (DataSource)   
envCtx2.lookup(jdbc/DBmultileague);
out.print(Connecting3 : );
  if (ds != null) {
out.print(Query1 : );
Connection conn = ds.getConnection();
out.print(Query2 : );
The context/resource definition:
Context path=/DBmultileague-0.1-dev  
docBase=DBmultileague-0.1-dev  debug=5 reloadable=true   
naming=true crossContext=true
   Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_DBmultileague_log. suffix=.txt   
timestamp=true/
   Resource name=jdbc/DBmultileague  
auth=Container  type=javax.sql.DataSource/
ResourceParams name=jdbc/DBmultileague
ParameternamemaxIdle/namevalue3000/value/Parameter
ParameternamemaxActive/namevalue10/value/Parameter
ParameternamemaxWait/namevalue10/value/Parameter
Parameternameusername/namevaluesa/value/Parameter
Parameternamepassword/namevalue/value/Parameter
Parameter
namefactory/name
 
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/Parameter
  Parameter

JNDI jdbc resources

2003-01-26 Thread Paul Carpenter
Hi All

I've scoured the list and got so close, yet so far from making the jdbc  
stuff work. With some help from Manav and other postings, this is what  
i see. can anyone solve the riddle?

Please see the cut'n'pastes below. I draw you attention to the fact  
that the connection looks good right up to the point where it's used -  
like the DataSource object is good (because ds != null is true), yet  
the getConnection method throws the often seen Cannot load JDBC driver  
class 'null' error.

I know this is very close...what's missing?

I'm sure my jars are in the right place, as a regular forClass approach  
in the same webapp works with no problems?


Thanks
Paul

tomcat 4.1.12, Mac OSX 10.2.3

Output from my test servlet:
Simple lookup test :
dbName : org.apache.commons.dbcp.BasicDataSource@25debb
list() on /comp/env Context :
Binding : jdbc: org.apache.naming.NamingContext
listBindings() on /comp/env Context :
Binding : jdbc:  
org.apache.naming.NamingContext:org.apache.naming.NamingContext@41f80c
list() on full Context :
Binding : DBmultileague: org.apache.commons.dbcp.BasicDataSource
listBindings() on full Context today:
Binding : DBmultileague:  
org.apache.commons.dbcp.BasicDataSource:org.apache.commons.dbcp.BasicDat 
aSource@25debb
Connecting1 : Connecting2 : Connecting3 : Query1 :

The relevant servlet code;
try {
out.println(list() on full Context : );
NamingEnumeration enum2 = ctx.list(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
out.println(listBindings() on full Context today: );
enum2 = ctx.listBindings(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
} catch (NamingException e) {
out.println(JNDI lookup failed :  + e);
}
try{
Context ctx2 = new InitialContext();
out.print(Connecting1 : );
 	Context envCtx2 = (Context)  
ctx2.lookup(java:/comp/env/);
out.print(Connecting2 : );
 		DataSource ds = (DataSource)  
envCtx2.lookup(jdbc/DBmultileague);
out.print(Connecting3 : );

  		if (ds != null) {
out.print(Query1 : );
		Connection conn = ds.getConnection();
out.print(Query2 : );

The context/resource definition:
Context path=/DBmultileague-0.1-dev docBase=DBmultileague-0.1-dev  
debug=5 reloadable=true  naming=true crossContext=true
		
	Logger className=org.apache.catalina.logger.FileLogger
			prefix=localhost_DBmultileague_log. suffix=.txt  
timestamp=true/

	Resource name=jdbc/DBmultileague auth=Container  
type=javax.sql.DataSource/
	
	ResourceParams name=jdbc/DBmultileague
		ParameternamemaxIdle/namevalue3000/value/Parameter
		ParameternamemaxActive/namevalue10/value/Parameter
		ParameternamemaxWait/namevalue10/value/Parameter
		Parameternameusername/namevaluesa/value/Parameter
		Parameternamepassword/namevalue/value/Parameter
		Parameter
			namefactory/name
			valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
		/Parameter
  	Parameter
			namedriverClassName/name
			valuecom.sybase.jdbc2.jdbc.SybDriver/value
		/Parameter
		Parameter
			nameurl/name
			valuejdbc:sybase:Tds:PowerBookPaul:11222/multiLeague/value
		/Parameter
		ParameternameinitialPoolSize/namevalue2/value/Parameter
	/ResourceParams


Re: JNDI jdbc resources

2003-01-26 Thread Peng Tuck Kwok
Let's have a look at your web.xml as well. Might be helpful.

Paul Carpenter wrote:

Hi All

I've scoured the list and got so close, yet so far from making the jdbc  
stuff work. With some help from Manav and other postings, this is what  
i see. can anyone solve the riddle?

Please see the cut'n'pastes below. I draw you attention to the fact  
that the connection looks good right up to the point where it's used -  
like the DataSource object is good (because ds != null is true), yet  
the getConnection method throws the often seen Cannot load JDBC driver  
class 'null' error.

I know this is very close...what's missing?

I'm sure my jars are in the right place, as a regular forClass approach  
in the same webapp works with no problems?


Thanks
Paul

tomcat 4.1.12, Mac OSX 10.2.3

Output from my test servlet:
Simple lookup test :
dbName : org.apache.commons.dbcp.BasicDataSource@25debb
list() on /comp/env Context :
Binding : jdbc: org.apache.naming.NamingContext
listBindings() on /comp/env Context :
Binding : jdbc:  
org.apache.naming.NamingContext:org.apache.naming.NamingContext@41f80c
list() on full Context :
Binding : DBmultileague: org.apache.commons.dbcp.BasicDataSource
listBindings() on full Context today:
Binding : DBmultileague:  
org.apache.commons.dbcp.BasicDataSource:org.apache.commons.dbcp.BasicDat 
aSource@25debb
Connecting1 : Connecting2 : Connecting3 : Query1 :

The relevant servlet code;
try {
out.println(list() on full Context : );
NamingEnumeration enum2 = ctx.list(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
out.println(listBindings() on full Context today: );
enum2 = ctx.listBindings(java:/comp/env/jdbc/);
while (enum2.hasMoreElements()) {
out.print(Binding : );
out.println(enum2.nextElement().toString());
}
} catch (NamingException e) {
out.println(JNDI lookup failed :  + e);
}
try{
Context ctx2 = new InitialContext();
out.print(Connecting1 : );
 Context envCtx2 = (Context)  
ctx2.lookup(java:/comp/env/);
out.print(Connecting2 : );
 DataSource ds = (DataSource)  
envCtx2.lookup(jdbc/DBmultileague);
out.print(Connecting3 : );

  if (ds != null) {
out.print(Query1 : );
Connection conn = ds.getConnection();
out.print(Query2 : );

The context/resource definition:
Context path=/DBmultileague-0.1-dev docBase=DBmultileague-0.1-dev  
debug=5 reloadable=true  naming=true crossContext=true
   
Logger className=org.apache.catalina.logger.FileLogger
prefix=localhost_DBmultileague_log. suffix=.txt  
timestamp=true/
   
Resource name=jdbc/DBmultileague auth=Container  
type=javax.sql.DataSource/

ResourceParams name=jdbc/DBmultileague
ParameternamemaxIdle/namevalue3000/value/Parameter
ParameternamemaxActive/namevalue10/value/Parameter
ParameternamemaxWait/namevalue10/value/Parameter
Parameternameusername/namevaluesa/value/Parameter
Parameternamepassword/namevalue/value/Parameter
Parameter
namefactory/name
valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/Parameter
  Parameter
namedriverClassName/name
valuecom.sybase.jdbc2.jdbc.SybDriver/value
/Parameter
Parameter
nameurl/name
valuejdbc:sybase:Tds:PowerBookPaul:11222/multiLeague/value
/Parameter
ParameternameinitialPoolSize/namevalue2/value/Parameter
/ResourceParams





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




Re: JNDI jdbc resources

2003-01-26 Thread shawn
What about server.xml?

  try{
  Context ctx2 = new InitialContext();
  out.print(Connecting1 : );
   Context envCtx2 = (Context)  
  ctx2.lookup(java:/comp/env/);
  out.print(Connecting2 : );
   DataSource ds = (DataSource)  
  envCtx2.lookup(jdbc/DBmultileague);
  out.print(Connecting3 : );
  
if (ds != null) {
  out.print(Query1 : );
  Connection conn = ds.getConnection();
  out.print(Query2 : );

That part worked for me too.  Is there an advantage to breaking your
Context into two pieces.  Anyway, I tried it like that with no problem.

Shawn


On Mon, 2003-01-27 at 09:21, Peng Tuck Kwok wrote:
 Let's have a look at your web.xml as well. Might be helpful.
 
 Paul Carpenter wrote:
  Hi All
  
  I've scoured the list and got so close, yet so far from making the jdbc  
  stuff work. With some help from Manav and other postings, this is what  
  i see. can anyone solve the riddle?
  
  Please see the cut'n'pastes below. I draw you attention to the fact  
  that the connection looks good right up to the point where it's used -  
  like the DataSource object is good (because ds != null is true), yet  
  the getConnection method throws the often seen Cannot load JDBC driver  
  class 'null' error.
  
  I know this is very close...what's missing?
  
  I'm sure my jars are in the right place, as a regular forClass approach  
  in the same webapp works with no problems?
  
  
  Thanks
  Paul
  
  tomcat 4.1.12, Mac OSX 10.2.3
  
  Output from my test servlet:
  Simple lookup test :
  dbName : org.apache.commons.dbcp.BasicDataSource@25debb
  list() on /comp/env Context :
  Binding : jdbc: org.apache.naming.NamingContext
  listBindings() on /comp/env Context :
  Binding : jdbc:  
  org.apache.naming.NamingContext:org.apache.naming.NamingContext@41f80c
  list() on full Context :
  Binding : DBmultileague: org.apache.commons.dbcp.BasicDataSource
  listBindings() on full Context today:
  Binding : DBmultileague:  
  org.apache.commons.dbcp.BasicDataSource:org.apache.commons.dbcp.BasicDat 
  aSource@25debb
  Connecting1 : Connecting2 : Connecting3 : Query1 :
  
  The relevant servlet code;
  try {
  out.println(list() on full Context : );
  NamingEnumeration enum2 = ctx.list(java:/comp/env/jdbc/);
  while (enum2.hasMoreElements()) {
  out.print(Binding : );
  out.println(enum2.nextElement().toString());
  }
  out.println(listBindings() on full Context today: );
  enum2 = ctx.listBindings(java:/comp/env/jdbc/);
  while (enum2.hasMoreElements()) {
  out.print(Binding : );
  out.println(enum2.nextElement().toString());
  }
  } catch (NamingException e) {
  out.println(JNDI lookup failed :  + e);
  }
  try{
  Context ctx2 = new InitialContext();
  out.print(Connecting1 : );
   Context envCtx2 = (Context)  
  ctx2.lookup(java:/comp/env/);
  out.print(Connecting2 : );
   DataSource ds = (DataSource)  
  envCtx2.lookup(jdbc/DBmultileague);
  out.print(Connecting3 : );
  
if (ds != null) {
  out.print(Query1 : );
  Connection conn = ds.getConnection();
  out.print(Query2 : );
  
  The context/resource definition:
  Context path=/DBmultileague-0.1-dev docBase=DBmultileague-0.1-dev  
  debug=5 reloadable=true  naming=true crossContext=true
 
  Logger className=org.apache.catalina.logger.FileLogger
  prefix=localhost_DBmultileague_log. suffix=.txt  
  timestamp=true/
 
  Resource name=jdbc/DBmultileague auth=Container  
  type=javax.sql.DataSource/
  
  ResourceParams name=jdbc/DBmultileague
  ParameternamemaxIdle/namevalue3000/value/Parameter
  ParameternamemaxActive/namevalue10/value/Parameter
  ParameternamemaxWait/namevalue10/value/Parameter
  Parameternameusername/namevaluesa/value/Parameter
  Parameternamepassword/namevalue/value/Parameter
  Parameter
  namefactory/name
  valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
  /Parameter
Parameter
  namedriverClassName/name
  valuecom.sybase.jdbc2.jdbc.SybDriver/value
  /Parameter
  Parameter
  nameurl/name
  valuejdbc:sybase:Tds:PowerBookPaul:11222/multiLeague/value
  /Parameter
  ParameternameinitialPoolSize/namevalue2/value/Parameter
  /ResourceParams
  
  
 
 
 
 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]
-- 
shawn [EMAIL