• 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

Tomcat4.1 ConnectionPool ( javax.naming.NameNot Found Exception: Name java:

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Pls help me how to do Connection pool in Tomcat4.1
I have written following lines in My jsp.
I have all jar files(naming-common.jar,naming-factory.jar,ojdbc14_g.jar,jndi.jar etc..) in tomcat\common\ lib folder
<%@ page import="javax.naming.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="java.sql.*"%>

<%
Connection conn=null;
Statement stmt=null;

try{
Context initContext = new InitialContext();
Context ctx=(Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)ctx.lookup("jdbc/timeDB");
conn = ds.getConnection();
stmt=conn.createStatement();
}catch(Exception e)
{System.out.println(" exception Created "+e);
}
%>


In server.xml file i added following lines

<Resource name="jdbc/timeDB" scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/timeDB">

<parameter><name>maxWait</name><value>5000</value></parameter>
<parameter><name>maxActive</name><value>20</value></parameter>
<parameter><name>password</name><value>xxxxxx</value></parameter>
<parameter><name>url</name><value>jdbc racle:thin:@xxxxxxx:1521:TESTING</value></parameter>
<parameter><name>driverClassName</name><value>oracle.jdbc.driver.OracleDriver</value></parameter>
<parameter><name>maxIdle</name><value>2</value></parameter>
<parameter><name>username</name><value>xxxxx</value></parameter>
</ResourceParams>

in web.xml i added folllowing lines

<resource-ref>
<description>oracle database</description>
<res-ref-name>jdbc/timeDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

<env-entry >
<env-entry-name>data.source.name</env-entry-name >
<env-entry-type>java.lang.String</env-entry-type >
<env-entry-value>jdbc/timeDB</env-entry-value >
</env-entry >

After running JSp , i am getting following errors:
exception Created javax.naming.NameNotFoundException: Name java: is not bound in this Context

Pls help : my Mail id is partha_samantaray@rediffmail.com


 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
have you got this before your connection pool declaration in server.xml?


replace contextname with your context name

here is mine
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!