hi,
i am trying to do MySql Connection Pooling in Tomcat 4.1.27. I am
getting the following error
------------------
javax.naming.NamingException: Cannot create resource instance
------------------
doing some googly revealed that i need some commons-.. jar files to be
present in common/lib folder. but i already had them in common/lib
folder. the files in lib folder are
--------------------------
activation.jar commons-dbcp.jar jdbc2_0-stdext.jar
naming-common.jar
ant.jar commons-logging-api.jar jndi.jar
naming-factory.jar
classes111.jar commons-pool.jar jta.jar
naming-resources.jar
classes12.jar jasper-compiler.jar mail.jar
servlet.jar
commons-collections.jar jasper-runtime.jar
mysql-connector-java-3.0.11-stable-bin.jar
-------------------------
my server.xml
<Context path="/student" docBase="student_directory" debug="0"
priveledge="true">
</Context>
<Context path="/testing" docBase="test" debug="0" priveledge="true">
<Resource name="jdbc/testDataSource" auth="Container"
type="java.sql.DataSource"/>
<ResourceParams name="jdbc/testDataSource">
<parameter>
<name>user</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/mysql</value>
</parameter>
</ResourceParams>
</Context>
------------------------------------
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>
<display-name>This is a test folder </display-name>
<description>
Welcome to the test folder
</description>
<resource-ref>
<description>MySql Datasource for Student Directory</description>
<res-ref-name>jdbc/testDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
-----------------------------
mysql_connection_test.jsp
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*"%>
<%@ page import="javax.sql.*"%>
<html>
<head>
<title>test</title>
</head>
<body>
<%
try
{
Context ctx= new InitialContext();
if(ctx==null)
throw new Exception("not able to find intial context");
DataSource
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/testDataSource");
if(ds!=null)
{
Connection conn=ds.getConnection();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select current_date()");
if(rs==null)
out.println("No rowset returned");
else
{
rs.next();
out.println("Current Date"+rs.getString(1));
}
rs.close();
stmt.close();
conn.close();
}
}
catch(Exception e)
{
out.println("Error found: "+e);
}
%>
</body>
</html>
-------------------------------------------
please help me in resolving it.
thanks
--
:)
Atishay Kumar
Btech, SEM VII
DA-IICT
Gandhinagar - 382009
India
ph: +91 9825383948
/****************************************************************************
* Learn the rules as you would need them to break them properly *
****************************************************************************/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]