Hello John
This is the source code of the file I am trying to run under tomcat
Is there any problem with connection string ???
It is working fine in %SQLLIB%\bin directory....
Here's the code
import java.sql.*;
import java.lang.*;
import java.io.*;
public class Ndb2servlet{
public static void main(String args[]) {
try{
Class.forName
("COM.ibm.db2.jdbc.app.DB2Driver").newInstance();
}
catch( Exception e)
{
System.out.println("\nDriver class not found
exception");
}
try{
Connection con = null;
// URL is jdbc:db2:dbname
String url = "jdbc:db2:sample";
if (args.length == 0)
{
// connect with default id/password
con = DriverManager.getConnection(url);
}
else if (args.length == 2)
{
String userid = args[0];
String passwd = args[1];
// connect with user-provided username and
password
con = DriverManager.getConnection(url, userid,
passwd);
}
else
{
System.out.println("\nUsage: java Ndb2servlet
[username password]\n");
System.exit(0);
}
// retrieve data from the database
System.out.println("Retrieve some data from the
database...");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from
db2admin.employee");
System.out.println("Received results:");
while (rs.next())
{
String a = rs.getString(1);
String str = rs.getString(2);
System.out.print(" empno= " + a);
System.out.print(" firstname= " + str);
System.out.print("\n");
}
rs.close();
stmt.close();
con.close();
}
catch (SQLException e1)
{
System.out.println("SQL Exception: "+ e1.getMessage
() + "\n");
}
}
}
------------------------------------------------------------------------------------
Nishant Awasthi
Corporate Systems Development
Progressive Insurance
"Turner,
John" To: 'Tomcat Users List'
<JTurner@AAS. <[EMAIL PROTECTED]>
com> cc: (bcc: Nishant Awasthi)
Subject: RE: Connection between TOMCAT
and
07/31/2002 DB2 ???
10:53 AM
Please
respond to
"Tomcat Users
List"
and 7.5) verify that the connection string inside the code is correct
John Turner
[EMAIL PROTECTED]
-----Original Message-----
From: Michael Remijan [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 10:52 AM
To: Tomcat Users List
Subject: RE: Connection between TOMCAT and DB2 ???
No,
It should be as simple as dropping the xxx.jar file (if it's xxx.zip rename
it to xxx.jar!) into the %TOMCAT_HOME%/common/lib directory.
I would do/verify the following
1) put tomcat in a directory structure where the names of the directories
don't contain spaces
2) make sure TOMCAT_HOME is set
3) make sure CATALINA_HOME=%TOMCAT_HOME%
4) copy xxx.jar to %TOMCAT_HOME%/common/lib
5) open a new DOS window to get the new values of the environment variables
6) change directory to %TOMCAT_HOME%/bin
7) issue c:\..>catalina.bat run
8) if it's still not working it's probably becuase the drivers are not 100%
java and rely on native method calls to some dll.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 9:40 AM
To: Tomcat Users List
Subject: RE: Connection between TOMCAT and DB2 ???
Mike
I don't understand by what you mean by 100% java native. But yes I am sure
that if I run my java code by placing my java file in C:\Program
Files\SQLLIB\bin directory
it works absolutely fine hence I can say it is java native to DB2
directory.
But I cannot make the same file run from outside the DB2 realm...that is
when I place same java file in TOMCAT_HOME directory it doesnot find the
driver...
DO I need to make changes in my server.xml file in %TOMCAT_HOME%\conf and
add some context
ot do I need to add some <Realm> information ???
Thanks
----------------------------------------------------------------------------
--------
Nishant Awasthi
Corporate Systems Development
Progressive Insurance
"Michael Remijan"
<Michael.Remijan@so To: "Tomcat Users List"
locup.com>
<[EMAIL PROTECTED]>
cc: (bcc: Nishant
Awasthi)
07/31/2002 10:13 AM Subject: RE: Connection
between TOMCAT and
Please respond to DB2 ???
"Tomcat Users List"
...
Here's a thought. are the drivers for DB2 100% java native. I'm
remembering a problem a colleage of mind had using the the jdbc drivers for
a database named Progress. It turns out they were not 100% java and relied
on calls to native libraries. If you're running on windows it'll be a dll
or something.
<mike/>
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 8:46 AM
To: Tomcat Users List
Subject: RE: Connection between TOMCAT and DB2 ???
Hello John,
It was a nice thinking but I didn't worked.
It is not finding the driver even now...I tried printing the
classpath..though it shows the
all 3 ".jar" files included but it is working only in %SQLLIB%\bin
directory that is if I try to run my file by keeping it in %SQLLIB%\bin
directory
it worked fine and retieve resultsets from database but
not from TOMCAT_HOME directory...
Any other tries..?
----------------------------------------------------------------------------
--------
Nishant Awasthi
Corporate Systems Development
Progressive Insurance
"Turner,
John" To: 'Tomcat Users List'
<JTurner@AAS. <[EMAIL PROTECTED]>
com> cc: (bcc: Nishant Awasthi)
Subject: RE: Connection
between TOMCAT and
07/31/2002 DB2 ???
09:27 AM
Please
respond to
"Tomcat Users
List"
Try renaming your .zip files to .jar files. Just change the extension from
.zip to .jar without changing the files themselves.
John Turner
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 9:22 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: Connection between TOMCAT and DB2 ???
Hello everyone...
thanks for showing interest in the list and to make it grow...
I have a situation here.
I am using tomcat 4.0.3 and jdk 1.3.1_04. I want to write a soap
service which will bring the resultset from IBM DB2 database.
Before implementing soap I am writing a simple Java "Ndb2servlet.java" file
inside
%TOMCAT_HOME%\webapps\soap\WEB-INF\classes
Now it compile fine but when I try to run it it says:
>>>>> COMPILING >>C:
\jakarta-tomcat-4.0.4\webapps\soap\WEB-INF\classes>javac Ndb2servlet.java
>>>>> RUNNING >>C:\jakarta-tomcat-4.0.4\webapps\soap\WEB-INF\classes>java
Ndb2servlet
SQL Exception: No suitable driver
I have tried to put db2java.zip, runtime.zip and sqlj.zip in %TOMCAT_HOME%
\common\lib and
and also included in system classpath then restarted TOMCAT but still it
couldn't find driver.
DO I need to do something special for my JAVA file in tomcat to find
"DB2driver"
Please help....
thanks
----------------------------------------------------------------------------
--------
Nishant Awasthi
Corporate Systems Development
Progressive Insurance
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>