473,606 Members | 2,444 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
ClassNotFoundEx ception for the COM.ibm.db2.jdb c.app.DB2Driver .

JSP-File
*************** *************** *************** *************** *************** *****
<html>
<head>
</head>
<%@ page language="java" import="java.sq l.*" %>
<body>
<h1>Mitarbeit er-Liste</h1>
<%
try {
Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver ");
System.out.prin tln(new java.util.Date( ).toString() + " DRIVER
FOUND.");
Connection db2Conn =
DriverManager.g etConnection("j dbc:db2:testdb" ,"db2admin","db 2admin");
Statement stmt = db2Conn.createS tatement();
String query ="select * from personal";
ResultSet myResultSet = stmt.executeQue ry(query);
if (myResultSet != null) {
while (myResultSet.ne xt()) {
String vorname = myResultSet.get String("vorname ");
String nachname = myResultSet.get String("nachnam e");
%>
<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_0 6\jre\lib

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

classpath:

CLASSPATH"...C: \entwicklung\To mcat4.0.2\webap ps\examples\WEB-INF\classes;C:\ entwicklung\Tom cat4.0.2\common \lib\servlet.ja r;C:\entwicklun g\Tomcat4.0.2\l ib\db2java.zip; C:\j2sdk1.4.2_0 6\jre\lib\db2ja va.zip;C:\sqlli b\java\db2java. zip"

Adding .newInstance() to the
Class.forName(" COM.ibm.db2.jdb c.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:t estdb";
Connection con;
String query ="SELECT * FROM personal";
Statement stmt;
try{
Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver ");
}
catch (java.lang.Clas sNotFoundExcept ion e) {
System.err.prin t("KlasseNichtG efundenAusnahme : ");
System.err.prin tln(e.getMessag e());
}
try {
System.out.prin tln("Versuche mich zu verbinden...");
con= DriverManager.g etConnection("j dbc:db2:testdb" ,"db2admin","db 2admin");
System.out.prin tln("Verbunden" );
stmt =con.createStat ement();
ResultSet result =stmt.executeQu ery(query);
while (result.next()) {
String name = result.getStrin g(1) +" "+
result.getStrin g(2);
System.out.prin tln(name);
}
stmt.close();
con.close();
}
catch(SQLExcept ion ex) {
System.err.prin t("SQLException :");
System.err.prin tln(ex.getMessa ge());
}

}
}

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

I would be happy to get any hints,

Andrea
Nov 12 '05 #1
1 4672
Andrea wrote:
Invoking the following jsp-file in the browser I get an
ClassNotFoundEx ception for the COM.ibm.db2.jdb c.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\com mon\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
4482
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 Server 6.1 with the SQL Server 2000 JDBC Driver. The background: 1. I have downloaded the SQL Server 2000 JDBC Driver and installed it on the web server.
0
2258
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 was working fine until a while ago. I haven't watched it recently, and haven't changed anything I am aware off right now. After I realized the problem I tried many 3.08 versions with the same symptom. Watch were it says "Unknown system variable...
0
4237
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 of MySQL 5.0? When trying to connect I am getting: ** BEGIN NESTED EXCEPTION **
4
6335
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 found that it was shifted three Bytes to the left, i.e. 4 becomes hex 4000000 which is 67108864 in decimal base. This means that the value written and the value read sometimes do not match, which is of course inacceptable for all real world...
2
13085
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 of this, the following call is failing: Connection.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR _READ_ONLY); with driver version:
5
5619
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 following code works fine for the same database: DB2XADataSource db2 = new DB2XADataSource(); db2.setDatabaseName("MYDB");
5
2026
oll3i
by: oll3i | last post by:
my librarybean package library.ejb; import java.sql.*; import javax.ejb.*; import library.common.*; @Stateless @Remote
2
4541
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 can. I'm using Eclipse 3.2.2 and I have installed mysql-connector-java-5.0.6-bin.jar. I am trying to connect to SQL Enterprise Manager version 8.0 innstall on a Windows 2003 Server Enterprise Edition. I have been able to successfully test...
3
22835
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, what are my options? Will I have to install db2 connect on every client machine that needs to connect to the DB2 servers? Is the DB2 Connect freely available or will we have to purchase it? I have also read on this group that we can install DB2...
0
8310
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6781
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5968
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5466
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3942
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3987
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2451
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1305
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.