• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

unable to implement connection pooling in sybase

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!