Connecting to db2/400 of AS400 through java throwing SQLException

S

savita

Hello,

I am trying to connect to db2/400 of as400 through java in WDSC.
I am usinf the driver ->
com.ibm.db2.jcc.DB2Driver
I have put the db2jcc.jar and db2jcc_license_c.jar in classpath.

I am not ableto connect with db2/400
The code for connecting to the database is follows-->

******************************************************************************
//Connect to a database
try
{
Connection conn = DriverManager.getConnection
("jdbc:db2:192.168.0.10","SAVITA","SAVITA");
}
catch (SQLException e)
{
System.out.println("SQL Exception: ");
}
*******************************************************************************
I am getting the following run time error
SQL Exception
.....................................................................................................
Do I have to use other url apart from jdbc:db2:192.168.0.10

I have used jdbc:db2:S650B66E

where S650B66E=system name
In the actual code instead of 192.168.0.10 they have used databasename.
My requirement is , to call stored procedure from db2/400 of as400.
Firstly how do I connect to db2/400?
Can please any body help me out.
Thanks
Regards
Savita
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

savita said:
I am trying to connect to db2/400 of as400 through java in WDSC.
I am usinf the driver ->
com.ibm.db2.jcc.DB2Driver
I have put the db2jcc.jar and db2jcc_license_c.jar in classpath.
//Connect to a database
try
{
Connection conn = DriverManager.getConnection
("jdbc:db2:192.168.0.10","SAVITA","SAVITA");
}
catch (SQLException e)
{
System.out.println("SQL Exception: ");

I strongly recommend you to print out e.
}
*******************************************************************************
I am getting the following run time error
SQL Exception
....................................................................................................
Do I have to use other url apart from jdbc:db2:192.168.0.10

I have used jdbc:db2:S650B66E

where S650B66E=system name

This should be in the DB2 JDBC docs.

I use a URL syntax like:

Connection con =
DriverManager.getConnection("jdbc:db2://localhost:50000/xxxx", "xxxx",
"xxxx");

where xxxx is database, username and password.

Arne
 
L

Lew

This should be in the DB2 JDBC docs.

E.g.,
<http://publib.boulder.ibm.com/infoc...sp?topic=/com.ibm.db2.udb.doc/ad/cjvjt2cn.htm>

"Syntax for a URL for the DB2 JDBC Type 2 Driver:
jdbc:db2:database

"database
A database alias. The alias refers to the DB2 database catalog entry on the
DB2 client."

This is for the case where there is a database catalog and a Type 2 driver.
I use a URL syntax like:

Connection con =
DriverManager.getConnection("jdbc:db2://localhost:50000/xxxx", "xxxx",
"xxxx");

where xxxx is database, username and password.

From
<http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0504vohra/index.html>

"The format of the DB2 JDBC Type 4 driver is jdbc:db2://<server>:<port>/<da...es I turned up googling around a bit. - Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top