Hello John,
I think you have sent an absolutely needed links...
It seems as the link suggests, it is the problem with
"jdbc:db2:sample"
I need something like
"jdbc:db2://n5533030:50000/sample" where
my database is "sample"
and port (actually I don't know what is my prt but I picked ): 50000
To find the port I looked into the services file and found:
db2cDB2MPP 50000/tcp #connection port for the DB2 instance
DB2MPP
db2iDB2MPP 50001/tcp #interrupt port for the DB2 instance
DB2MPP
DB2CCMSRV 50006/tcp #DB2 Performance Monitor Listener
db2cDB2DAS00 523/tcp #connection port for the DB2 instance
DB2DAS00
db2iDB2DAS00 524/tcp #interrupt port for the DB2 instance
DB2DAS00
DB2_DB2MPP 50007/tcp
DB2_DB2MPP_END 50010/tcp
There are all the port informaiton I can find...Since while installing I
had Db2MPP
instance created...I picked up 50000 as my jdbc URL port.
and Yes, I tried using both .app and .net in my connection string it didn't
work...
Aww....Is didn't work....
I appreciate your help,
------------------------------------------------------------------------------------
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 ???
11:22 AM
Please
respond to
"Tomcat Users
List"
I don't have any experience with DB2, so I'm not sure how much help I can
be.
Two things I noticed: you don't check for valid values or null for userid
and passwd. Are the usernames and passwords you are using valid on that
database?
Also, according to this URL:
http://www-3.ibm.com/software/data/db2/java/v5/faq.html#q7 if you are
using
the "app" driver your URL should look like this:
"jdbc:db2://server:port/database".
Shouldn't you be using the "net" driver if you are trying to connect
through
a servlet?
John Turner
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 31, 2002 11:10 AM
To: Tomcat Users List
Subject: RE: Connection between TOMCAT and DB2 ???
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
--
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]>