473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

jsp - jdbc connection to db2v8 failing

Hello,

I spent now several hours searching the google groups without finding
an solution. I am kind of Newbie to DB2 and JSP and therefore working
with JSP4Dummies (not sure whether I should recommend this book):

Invoking the following jsp-file in the browser I get an
ClassNotFoundException for the COM.ibm.db2.jdbc.app.DB2Driver.

JSP-File
************************************************** ******************************
<html>
<head>
</head>
<%@ page language="java" import="java.sql.*" %>
<body>
<h1>Mitarbeiter-Liste</h1>
<%
try {
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
System.out.println(new java.util.Date().toString() + " DRIVER
FOUND.");
Connection db2Conn =
DriverManager.getConnection("jdbc:db2:testdb","db2 admin","db2admin");
Statement stmt = db2Conn.createStatement();
String query ="select * from personal";
ResultSet myResultSet = stmt.executeQuery(query);
if (myResultSet != null) {
while (myResultSet.next()) {
String vorname = myResultSet.getString("vorname");
String nachname = myResultSet.getString("nachname");
%>
<br>
<b><%= vorname%>&nbsp;&nbsp;<%= nachname%></b>
<br>
<%
}
}
stmt.close();
db2Conn.close();

}
catch(Exception e)
{
out.println(new java.util.Date().toString() + " Error 1:
"+e.getMessage());
}
%>
</body>
</html>

************************************************** ******************************

My Environment:

- DB2 v8.1.7
- j2sdk1.4.2_06
- Tomcat4.0.2
- OS: Windows XP Professional

To connect to the database I am using db2java.zip (C:\SQLLIB\java)
which I copied to C:\entwicklung\Tomcat4.0.2\lib\ and to

C:\j2sdk1.4.2_06\jre\lib

Normally the ClassNotFoundExceptions has to do something with the
Classpath but I already included the db2java.zip into the

classpath:

CLASSPATH"...C:\entwicklung\Tomcat4.0.2\webapps\ex amples\WEB-INF\classes;C:\entwicklung\Tomcat4.0.2\common\lib\ servlet.jar;C:\entwicklung\Tomcat4.0.2\lib\db2java .zip;C:\j2sdk1.4.2_06\jre\lib\db2java.zip;C:\sqlli b\java\db2java.zip"

Adding .newInstance() to the
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver") is not making any
difference.
Surprisingly the following java file (doing pretty much the same) can
be compiled (javac) and executed (command prompt) without any problems
in the same environment.

JAVA-File
************************************************** ******************************
import java.sql.*;
public class TestQuery {
public TestQuery() {
}
public static void main(String args[]) {
String url="jdbc:db2:testdb";
Connection con;
String query ="SELECT * FROM personal";
Statement stmt;
try{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
}
catch (java.lang.ClassNotFoundException e) {
System.err.print("KlasseNichtGefundenAusnahme: ");
System.err.println(e.getMessage());
}
try {
System.out.println("Versuche mich zu verbinden...");
con= DriverManager.getConnection("jdbc:db2:testdb","db2 admin","db2admin");
System.out.println("Verbunden");
stmt =con.createStatement();
ResultSet result =stmt.executeQuery(query);
while (result.next()) {
String name = result.getString(1) +" "+
result.getString(2);
System.out.println(name);
}
stmt.close();
con.close();
}
catch(SQLException ex) {
System.err.print("SQLException:");
System.err.println(ex.getMessage());
}

}
}

************************************************** ******************************

I would be happy to get any hints,

Andrea
Nov 12 '05 #1
1 4654
Andrea wrote:
Invoking the following jsp-file in the browser I get an
ClassNotFoundException for the COM.ibm.db2.jdbc.app.DB2Driver.

[...]

Are you sure Tomcat uses this classpath? If started as a service, it's
quite probable that it uses a different one.

Try converting the db2java.zip to a jar (Tomcat 5 requires libraries to
be .jar files, not .zip) and putting it into
C:\entwicklung\Tomcat4.0.2\common\lib (restart Tomcat afterwards, obviously)

hth,
Benjamin
--
Please compose your messages as plaintext:
http://www.netby.dk/Oest/Europa-Alle/vermeer/plain.html
And do not send MS Office attachments:
http://www.goldmark.org/netrants/no-word/attach.html
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: JShurmatz | last post by:
If anyone can shed some light on this problem I would greatly appreciate it. I am unsuccessfully trying to use a database connnection retrieved from a pool configured using Java System Web...
0
by: Nils Valentin | last post by:
Hi MySQL Fans ;-), Is it possible that the 3.08 series allows to connect to 4.0.14 versions but not to the 4.1 alpha-versions ? I get belows error when tryig to connect from DbVisualizer which...
0
by: Robert Mazur | last post by:
MySQL 5.0 alpha (binary install) on Solaris 9 -or- RedHat 8.0 mysql-connector-java-3.0.8-stable ----------------------- Is there something different going on with JDBC and the alpha version...
4
by: Dani | last post by:
Hi everyone Description of the problem: Using a PreparedStatement to write down an integer (int) plus a timestamp for testing purposes. When read out again the integer looks very different. We...
2
by: Satish Gupta | last post by:
I am using DB2 version 7.2 on Windows 2000. I just installed Fixpack 12 as well. This driver is not working with a third-party software. The vendor claims that this driver is too old. As a proof...
5
by: Steffen | last post by:
hi there, i have a problem connecting to a db2 database 7.2.4 on AIX using java when running the javacode on AIX using jdk1.3.1. The classpath is correctly set to java12/... on windows the...
5
oll3i
by: oll3i | last post by:
my librarybean package library.ejb; import java.sql.*; import javax.ejb.*; import library.common.*; @Stateless @Remote
2
by: bevis | last post by:
I'm new to sql server and mysql but this seems like it should be a pretty straight forward jdbc connection. But I have spent almost 2 days just trying to get a jdbc connection. Please help if you...
3
by: Anoop | last post by:
Is it true that there are no type 4 jdbc drivers to connect to a DB2 server v7.1? The DB2 server is hosted on ACF2 (OS/390). We would be connecting from windows and solaris boxes. If it is true,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.