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: <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]>




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

Reply via email to