File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
partha sarathi
Greenhorn
Posts: 1
  • 0
  • 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


 
Rich Walton
Greenhorn
Posts: 4
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic