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
 
  url
  jdbc:sapdb://[url or ip]/[db name]
  

instead of  
jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague

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 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.
  
  
jdbc/DBmultileague

  
javax.sql.DataSource
  
  
Container
  

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:

   
prefix="localhost_DBmultileague_log." suffix=".txt"
timestamp="true"/>
   

 
maxIdle3000
 
maxActive10
maxWait10
 
usernamesa
password

factory
  
org.apache.commons.dbcp.BasicDataSourceFactory

  
driverClassName
com.sybase.jdbc2.jdbc.SybDriver


 

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
 
  url
  jdbc:sapdb://[url or ip]/[db name]
  

instead of jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague

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 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.
  
  
jdbc/DBmultileague

  
javax.sql.DataSource
  
  
Container
  




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:

   
prefix="localhost_DBmultileague_log." suffix=".txt"   
timestamp="true"/>
   

maxIdle3000
maxActive10
maxWait10
usernamesa
password

factory
 
org.apache.commons.dbcp.BasicDataSourceFactory

  
driverClassName
com.sybase.jdbc2.jdbc.SybDriver


url
 
jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague

 
initialPoolSize2





--
To unsubscribe, e-mail:

For additional commands, e-mail:  




--
To unsubscribe, e-mail:   

For additional commands, e-mail: 






--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: JNDI jdbc resources

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

just to confirm,

this is not your server.xml
 > >   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 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.
>   
>   
>   jdbc/DBmultileague
>   
>   
>   javax.sql.DataSource
>   
>   
>   Container
>   
>   
-- 
shawn <[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




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 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.
  		
  		
		jdbc/DBmultileague
		
  		
		javax.sql.DataSource
  		
  		
			Container
  		
	



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:

   
prefix="localhost_DBmultileague_log." suffix=".txt"   
timestamp="true"/>
   

maxIdle3000
maxActive10
maxWait10
usernamesa
password

factory
 
org.apache.commons.dbcp.BasicDataSourceFactory

  
driverClassName
com.sybase.jdbc2.jdbc.SybDriver


url
 
jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague

 
initialPoolSize2




--
To unsubscribe, e-mail:

For additional commands, e-mail:  




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




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:
> >  > debug="5" reloadable="true"  naming="true" crossContext="true">
> >
> >  > prefix="localhost_DBmultileague_log." suffix=".txt"  
> > timestamp="true"/>
> >
> >  > type="javax.sql.DataSource"/>
> > 
> > 
> > maxIdle3000
> > maxActive10
> > maxWait10
> > usernamesa
> > password
> > 
> > factory
> > org.apache.commons.dbcp.BasicDataSourceFactory
> > 
> >   
> > driverClassName
> > com.sybase.jdbc2.jdbc.SybDriver
> > 
> > 
> > url
> > jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague
> > 
> > initialPoolSize2
> > 
> > 
> > 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
-- 
shawn <[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




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:

   

prefix="localhost_DBmultileague_log." suffix=".txt"  
timestamp="true"/>
   



maxIdle3000
maxActive10
maxWait10
usernamesa
password

factory
org.apache.commons.dbcp.BasicDataSourceFactory

  
driverClassName
com.sybase.jdbc2.jdbc.SybDriver


url
jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague

initialPoolSize2






--
To unsubscribe, e-mail:   
For additional commands, e-mail: