Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Error when I try to connect to DB2 from JAVA

31 views
Skip to first unread message

shivas

unread,
Sep 8, 2003, 12:52:23 AM9/8/03
to
Hi,
I am trying to connect to DB2 database from JAVA.
This is following piece of code i am using to connect to DB2 database

Class.forName("com.ibm.db2.jcc.DB2Driver");
Connection connection = DriverManager.getConnection(
"jdbc:db2://devdb:6004/dev",
"db2admin",
"db2admin");

And i am using the JDBC drivers provided in the
/SQLLIB/java/db2jcc.jar of the DB2 installation directorty,

But i get the following exception:
com.ibm.db2.jcc.c.SqlException: IO Exception opening socket to server
papdevdb on port 6004. The DB2 Server may be down.
at com.ibm.db2.jcc.a.a.<init>(a.java:110)
at com.ibm.db2.jcc.a.b.a(b.java:1116)
at com.ibm.db2.jcc.c.l.<init>(l.java:212)
at com.ibm.db2.jcc.a.b.<init>(b.java:190)

But I have verified that the DB server is up, by connecting directly
to the server.
_____________________________________________________________________________
I have also tried to connect using the another driver :
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
Connection connection = DriverManager.getConnection(
"jdbc:db2://devdb:6004/dev",
"db2admin",
"db2admin");
And i am using the JDBC drivers provided in the
/SQLLIB/java/db2java.zip of the DB2 installation directorty,
But i get the following exception:
COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0616E Error
opening socket. SQLSTATE=08S01
at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.socketException(SQLExceptionGenerator.java:646)
at COM.ibm.db2.jdbc.net.DB2Connection.create(DB2Connection.java:330)
at COM.ibm.db2.jdbc.net.DB2Connection.<init>(DB2Connection.java:256)
at COM.ibm.db2.jdbc.net.DB2Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestDB2Connection.main(TestDB2Connection.java:37)


As i am new to DB2, any type of help would be great!!!,

Thanks,
Shivas

shivas

unread,
Sep 8, 2003, 10:36:37 AM9/8/03
to
Hi All,

Using db2jstrt <portnumber> had set the jstrt running and this sovled the probelm

Thanks,
shivas

PM (pm3iinc-nospam)

unread,
Sep 9, 2003, 2:19:06 PM9/9/03
to
try with port 50000
//localhost:50000/DBNAME


DB2 Get DBM Cfg
TCP/IP Service name (SVCENAME) = db2c_DB2

On windows, see the file %SystemRoot%\system32\drivers\etc\services
type %SystemRoot%\system32\drivers\etc\services | find /i "db2c_DB2"
You should see something like this : db2c_DB2 50000/tcp

PM

"shivas" <shi...@mindtree.com> a écrit dans le message de
news:f2c2908d.03090...@posting.google.com...

rashmimakhijani

unread,
Oct 30, 2003, 2:13:12 AM10/30/03
to

Originally posted by Shivas

> Hi All,

>

>

> Thanks,

> shivas

Hi Shivas,

Can you please explain what is db2jstrt .If possible can you send the
code snippet for connection as i am facing the same problem.

my code is

String url="jdbc:db2://ind-spz7w2s1014:50000/TESTDB2";

String userName = "db2admin";

String password = "db2admin";

DriverManager.registerDriver((Driver)Class.fo-
rName("COM.ibm.db2.jdbc.net.DB2Driver").newIn-
stance());

con = DriverManager.getConnection(url,userName,password); //line 32

and my error is

COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0616E Error
opening socket. SQLSTATE=08S01

at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.socketException(U-
nknown Source)

at COM.ibm.db2.jdbc.net.DB2Connection.create(Unknown Source)

at COM.ibm.db2.jdbc.net.DB2Connection.<init>(Unknown Source)

at COM.ibm.db2.jdbc.net.DB2Driver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:543)

at java.sql.DriverManager.getConnection(DriverManager.java:194)

at Testingconn1.getConnection(Testingconn1.java:32)

at Testingconn1.main(Testingconn1.java:48)


--
Posted via http://dbforums.com

0 new messages