tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jitendra Kharche" <Jitendra.Khar...@geometricsoftware.com>
Subject Using Datasource for cloudscape
Date Mon, 26 Jun 2006 05:08:18 GMT

Hi there, can anybody help me on this.

Hi Dilan have you any more clue on this.

Problem:
I am using Tomcat 5.5.17 and tried running a sample datasource
application having a jsp page (see contents below) using the Cloudscape
database. I have added the driver jar into CATALINA_HOME/common/lib
directory. When I run the jsp I get following exception
WARNING: Unexpected exception resolving reference
java.lang.NoSuchMethodException:
com.ibm.db2j.jdbc.DB2jDataSource.setScope(boolean)
        at java.lang.Class.getMethod(Class.java:1581)
        at
com.ibm.db2j.jdbc.DB2jAbstractDataSource.getObjectInstance(Unknown
Source)
	  ........

************************************************************************
********
Contents of file CATALINA_HOME/webapps/myApp/dbdemo.jsp
************************************************************************
********
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
<%	
Connection con = null;
Statement stmt = null;
try {
	Context initContext = new InitialContext();
	Context envContext  =
(Context)initContext.lookup("java:comp/env");
	DataSource ds = (DataSource)envContext.lookup("jdbc/MyDB");
	System.out.println("Got DataSource\n");
	con = ds.getConnection();
	System.out.println("Got Connection\n"); }
catch(java.lang.Exception e) {
	e.printStackTrace();
	System.err.print(e.getClass().getName());
	System.err.println(e.getMessage());
}

try {
	stmt = con.createStatement();	
	ResultSet rs = stmt.executeQuery("SELECT * FROM employee");
	System.out.println("Table assignment after insertion:");
	%>
	Your table contains the following entries:<BR>
	<table>
	
<tr><B><th>emp_id</th><th>emp_name</th><th>emp_dept</th></B></tr>
	<%
	while (rs.next()) {
		String emp_id = rs.getString("emp_id");
		String emp_name  = rs.getString("emp_name");
		String emp_dept = rs.getString("emp_dept");
	%>
	<tr>
	
<td><%=emp_id%></td><td><%=emp_name%></td><td><%=emp_dept%></td>
	</tr>
	</table>
	<%
	}
	rs.close(); stmt.close(); con.close();
}
catch(java.lang.Exception e) {
	e.printStackTrace();
}%>

************************************************************************
********
Contents of file CATALINA_HOME/conf/server.xml
************************************************************************
********
<?xml version="1.0" encoding="UTF-8"?>
<Server>
  <Listener className="org.apache.catalina.core.AprLifecycleListener"/>
  <Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/
>
  <Listener
className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"
/>
  <Listener
className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
  <GlobalNamingResources>
    <Environment name="simpleValue" type="java.lang.Integer"
value="30"/>
    <Resource auth="Container"
      description="User database that can be updated and saved"
      name="UserDatabase" type="org.apache.catalina.UserDatabase"
      pathname="conf/tomcat-users.xml"
      factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
    <Resource name="jdbc/MyDB" type="javax.sql.DataSource"
      password="password" driverClassName="com.ibm.db2j.jdbc.DB2jDriver"
      maxIdle="2" maxWait="5000" username="user"
 
url="jdbc:db2j:E:/apache-tomcat-5.5.17/webapps/datasourcedemo/SampleDB"
      maxActive="4"/>
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080" redirectPort="8443" minSpareThreads="25"
        connectionTimeout="20000" maxSpareThreads="75" maxThreads="150">
    </Connector>
    <Connector port="8009" redirectPort="8443" protocol="AJP/1.3">
    </Connector>
    <Engine defaultHost="localhost" name="Catalina">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
      <Host appBase="webapps" name="localhost">
      </Host>
    </Engine>
  </Service>
</Server>

************************************************************************
********
Contents of file CATALINA_HOME/webapps/myApp/WEB-INF/web.xml
************************************************************************
********
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
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">
	<display-name>
	datasourcedemo</display-name>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>

	<resource-ref>
		<res-ref-name>jdbc/MyDB</res-ref-name>
		<res-type>javax.sql.DataSource</res-type>
		<res-auth>Container</res-auth>
	</resource-ref>
</web-app>

************************************************************************
********
Contents of file CATALINA_HOME/webapps/myApp/META-INF/context.xml
************************************************************************
********
<?xml version="1.0" encoding="UTF-8"?>
<Context>
  <Resource auth="Container" name="jdbc/MyDB"
type="com.ibm.db2j.jdbc.DB2jDataSource"
    password="password" driverClassName="com.ibm.db2j.jdbc.DB2jDriver"
    factory="com.ibm.db2j.jdbc.DB2jConnectionPoolDataSource"
    maxIdle="4" testOnBorrow="true" validationQuery="select 1"
username="user"
 
url="jdbc:db2j:E:/apache-tomcat-5.5.17/webapps/datasourcedemo/SampleDB"
    timeBetweenEvictionRunsMillis="30000" maxActive="8"/> </Context>
 
Regards,
Jitendra Kharche


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe,
e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message