This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Tomcat and the fly likes unable to implement connection pooling in sybase Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "unable to implement connection pooling in sybase " Watch "unable to implement connection pooling in sybase " New topic
Author

unable to implement connection pooling in sybase

Bhavani Kumar
Greenhorn

Joined: Feb 22, 2005
Posts: 15
hello everyone,
i am trying to implement connection pooling with sybase as the database and tomcat 5 as the container. But this is the exception thats coming :

javax.naming.NameNotFoundException: Name jdbc/TestDB2 is not bound in
this Context

My server.xml looks lilke this :
<Context path="/DBTest2" docBase="DBTest2" debug="5" reloadable="true" crossContext="true" >

<Logger classname="org.apache.catalina.logger.FileLogger"
prefix="localhost_DBTest2_log." suffix=".txt" timestamp="true" />

<Resource name="jdbc/TestDB2" auth="Container" type="javax.sql.DataSource" />

<ResourceParams name="jdbc/TestDB2">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>

<parameter>
<name>maxIdle</name>
<value>30</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<parameter>
<name>username</name>
<value>sa</value>
</parameter>

<parameter>
<name>password</name>
<value></value>
</parameter>

<parameter>
<name>driverClassName</name>
<value>com.sybase.jdbc2.jdbc.SybDriver</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbc:sybase:Tds:172.16.12.84:2048/lnk_common_dd</value>
</parameter>

</ResourceParams>

</Context>

This is my web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<description>MySQL Test App</description>
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/TestDB2</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>


this is my test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<sql:query var="rs" dataSource="jdbc/TestDB2">
select id, foo, bar from testdata
</sql:query>

<html>
<head>
<title>DB Test</title>
</head>
<body>

<h2>Results</h2>

<c:forEach var="row" items="${rs.rows}">
Foo ${row.foo}<br/>
Bar ${row.bar}<br/>
</c:forEach>

</body>
</html>

Any help would be much appreciated as i am stuck with this since the last 2 days

thanking you all in advance

Bhavani
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Visually, I do not see any syntax errors. So how did you access your test.jsp(url) page. Based on your configurations it should have been something like this...

CATALINA_HOME/webapps/DBTest2/test.jsp




Yes?
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Also, another suggestion is to check the log file(catalina.out) or console and verify that the context /DBTest2 was loaded without any problems.
Bhavani Kumar
Greenhorn

Joined: Feb 22, 2005
Posts: 15
yeah craig, i am accessing test.jsp by localhost:8080/DBTest2/test.jsp and the context /DBTest2 is loading properly. can you suggest alternative methods of implementing connection pooling apart from the method i am following.

Thanks
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I did the same test as you did, modifying the server.xml(minus the logging config), but I was testing DBCP for a MySQL database and it worked fine. I also declared all of my parameters inside the Resource tag .i.e


But anyway, I decided to move my configurations from the server.xml to the context.xml. Which is an alternative from modifying the server.xml. And that is to create a context.xml of your DBCP configurations and place it in your META-INF directory of your web application(s).

But I believe I may see a problem with you server.xml...



The above code shows that you have terminated the Resource tag with the "/>", so none of your resource parameters were linked to this particular resource.

Your modified server.xml:




I hope this helps.
Bhavani Kumar
Greenhorn

Joined: Feb 22, 2005
Posts: 15
hi craig,

the problem still persists even after making the changes that you have suggested.

regarding closing of Resource tag: Since we are mapping the 'name' attribute of ResourceParams with the 'name' attribute of Resource , so there would not be much of a problem. But still i've tried by changing it,still the problem persists.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I took your configurations verbatim and tried it. I was unable to get it to work. I did not get the same error as you did, so I modified your configurations(I used a MySQL database) by assigning all of the attributes in the Resource element. I also placed my configurations right before the </Host> end tag. This is the same configurations in my context.xml.

 
jQuery in Action, 2nd edition
 
subject: unable to implement connection pooling in sybase
 
Similar Threads
Trouble Configuring a Data Source for MySQL using JSTL in JBoss
Tomcat with MySQL Connection Pool
Configure tomcat resource factory
unable to implement connection pooling with sybase
Connection pooling for Ms SQL