You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul Carpenter <pe...@yt.catv.ne.jp> on 2003/01/26 15:22:46 UTC
JNDI jdbc resources
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">
<Parameter><name>maxIdle</name><value>3000</value></Parameter>
<Parameter><name>maxActive</name><value>10</value></Parameter>
<Parameter><name>maxWait</name><value>10</value></Parameter>
<Parameter><name>username</name><value>sa</value></Parameter>
<Parameter><name>password</name><value></value></Parameter>
<Parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</Parameter>
<Parameter>
<name>driverClassName</name>
<value>com.sybase.jdbc2.jdbc.SybDriver</value>
</Parameter>
<Parameter>
<name>url</name>
<value>jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague</value>
</Parameter>
<Parameter><name>initialPoolSize</name><value>2</value></Parameter>
</ResourceParams>
Re: JNDI jdbc resources
Posted by shawn <ja...@koyuru.com>.
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">
> > <Parameter><name>maxIdle</name><value>3000</value></Parameter>
> > <Parameter><name>maxActive</name><value>10</value></Parameter>
> > <Parameter><name>maxWait</name><value>10</value></Parameter>
> > <Parameter><name>username</name><value>sa</value></Parameter>
> > <Parameter><name>password</name><value></value></Parameter>
> > <Parameter>
> > <name>factory</name>
> > <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> > </Parameter>
> > <Parameter>
> > <name>driverClassName</name>
> > <value>com.sybase.jdbc2.jdbc.SybDriver</value>
> > </Parameter>
> > <Parameter>
> > <name>url</name>
> > <value>jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague</value>
> > </Parameter>
> > <Parameter><name>initialPoolSize</name><value>2</value></Parameter>
> > </ResourceParams>
> >
> >
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
shawn <ja...@koyuru.com>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JNDI jdbc resources
Posted by Paul Carpenter <pe...@yt.catv.ne.jp>.
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>
> <name>url</name>
> <value>jdbc:sapdb://[url or ip]/[db name]</value>
> </parameter>
>
> instead of
> <value>jdbc: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 name="jdbc/DBmultileague"
>>>> auth="Container" type="javax.sql.DataSource"/>
>>>> <ResourceParams name="jdbc/DBmultileague">
>>>>
>>>> <Parameter><name>maxIdle</name><value>3000</value></Parameter>
>>>>
>>>> <Parameter><name>maxActive</name><value>10</value></Parameter>
>>>> <Parameter><name>maxWait</name><value>10</value></Parameter>
>>>>
>>>> <Parameter><name>username</name><value>sa</value></Parameter>
>>>> <Parameter><name>password</name><value></value></Parameter>
>>>> <Parameter>
>>>> <name>factory</name>
>>>>
>>>> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>>>> </Parameter>
>>>> <Parameter>
>>>> <name>driverClassName</name>
>>>> <value>com.sybase.jdbc2.jdbc.SybDriver</value>
>>>> </Parameter>
>>>> <Parameter>
>>>> <name>url</name>
>>>>
>>>> <value>jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague</value>
>>>> </Parameter>
>>>>
>>>> <Parameter><name>initialPoolSize</name><value>2</value></Parameter>
>>>> </ResourceParams>
>>>
>>>
>>>
>>>
>>> --
>>> To unsubscribe, e-mail:
>>> <ma...@jakarta.apache.org>
>>> For additional commands, e-mail:
>>> <ma...@jakarta.apache.org>
>>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JNDI jdbc resources
Posted by Peng Tuck Kwok <pe...@makmal.net>.
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>
<name>url</name>
<value>jdbc:sapdb://[url or ip]/[db name]</value>
</parameter>
instead of <value>jdbc: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">
>>> <Parameter><name>maxIdle</name><value>3000</value></Parameter>
>>> <Parameter><name>maxActive</name><value>10</value></Parameter>
>>> <Parameter><name>maxWait</name><value>10</value></Parameter>
>>> <Parameter><name>username</name><value>sa</value></Parameter>
>>> <Parameter><name>password</name><value></value></Parameter>
>>> <Parameter>
>>> <name>factory</name>
>>>
>>> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>>> </Parameter>
>>> <Parameter>
>>> <name>driverClassName</name>
>>> <value>com.sybase.jdbc2.jdbc.SybDriver</value>
>>> </Parameter>
>>> <Parameter>
>>> <name>url</name>
>>>
>>> <value>jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague</value>
>>> </Parameter>
>>>
>>> <Parameter><name>initialPoolSize</name><value>2</value></Parameter>
>>> </ResourceParams>
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <ma...@jakarta.apache.org>
>> For additional commands, e-mail:
>> <ma...@jakarta.apache.org>
>>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JNDI jdbc resources
Posted by shawn <ja...@koyuru.com>.
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 <ja...@koyuru.com>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JNDI jdbc resources
Posted by Paul Carpenter <pe...@yt.catv.ne.jp>.
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">
>> <Parameter><name>maxIdle</name><value>3000</value></Parameter>
>> <Parameter><name>maxActive</name><value>10</value></Parameter>
>> <Parameter><name>maxWait</name><value>10</value></Parameter>
>> <Parameter><name>username</name><value>sa</value></Parameter>
>> <Parameter><name>password</name><value></value></Parameter>
>> <Parameter>
>> <name>factory</name>
>>
>> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>> </Parameter>
>> <Parameter>
>> <name>driverClassName</name>
>> <value>com.sybase.jdbc2.jdbc.SybDriver</value>
>> </Parameter>
>> <Parameter>
>> <name>url</name>
>>
>> <value>jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague</value>
>> </Parameter>
>>
>> <Parameter><name>initialPoolSize</name><value>2</value></Parameter>
>> </ResourceParams>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: JNDI jdbc resources
Posted by Peng Tuck Kwok <pe...@makmal.net>.
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">
> <Parameter><name>maxIdle</name><value>3000</value></Parameter>
> <Parameter><name>maxActive</name><value>10</value></Parameter>
> <Parameter><name>maxWait</name><value>10</value></Parameter>
> <Parameter><name>username</name><value>sa</value></Parameter>
> <Parameter><name>password</name><value></value></Parameter>
> <Parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </Parameter>
> <Parameter>
> <name>driverClassName</name>
> <value>com.sybase.jdbc2.jdbc.SybDriver</value>
> </Parameter>
> <Parameter>
> <name>url</name>
> <value>jdbc:sybase:Tds:PowerBookPaul:11222/multiLeague</value>
> </Parameter>
> <Parameter><name>initialPoolSize</name><value>2</value></Parameter>
> </ResourceParams>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>