aspose file tools*
The moose likes Servlets and the fly likes Tomcat-MySql Connection pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tomcat-MySql Connection pooling" Watch "Tomcat-MySql Connection pooling" New topic
Author

Tomcat-MySql Connection pooling

Jim Smithian
Greenhorn

Joined: Sep 21, 2004
Posts: 18
Hi,

I am doing a project for a graduate course using Tomcat, Servlets and MySql. I want to use connection pooling for access to database. I have some problems in the connection pooling. I am not looking for a quick fix, but I want to understand the concepts of connection pooling, data source, JNDI, name binding etc,. I'd like to know what is context, IninialContext etc.
By understanding these topics I can follow the setup documentation and understand and interpret the error messages.

Can anyone please, explain these things or refer me to some on-line tutorials or books.

Here is part of my code and the error message from invoking the servlet:

Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");

DataSource ds = (DataSource) envCtx.lookup("jdbc/Diary ");
Connection conn = ds.getConnection();

Statement s = conn.createStatement();
ResultSet R = s.executeQuery("select * from aTable");

When I run the program I get the following error message:

An exception occured:
Name Diary is not bound in this Context
CLASSPATH :\programfiles\SunJ2EE\jdk\lib\tools.jar;D:\programfiles\jakarta-tomcat-5.0.28\bin\bootstrap.jar
Details:

javax.naming.NameNotFoundException: Name Diary is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:768)
at

which I think is because of wrong configuration of Tomcat (server,xml, web.xml etc)


Thanks.

Jim
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Maybe you can post your xml files that define your DataSource. It appears it is kind of like having a file in c:\folder\data\myfile.txt and you are trying to look in c:\data\myfile.txt.

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat-MySql Connection pooling