Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Connecting to db2/400 of AS400 through java throwing SQLException

Reply
Thread Tools

Connecting to db2/400 of AS400 through java throwing SQLException

 
 
savita
Guest
Posts: n/a
 
      12-29-2006
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

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      12-29-2006
savita wrote:
> 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

 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      12-30-2006
savita wrote:
>> Do I have to use other url apart from jdbc:db2:192.168.0.10


Arne Vajh°j wrote:
> This should be in the DB2 JDBC docs.


E.g.,
<http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?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.

Arne Vajh°j wrote:
> 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 [URL] is
jdbc:db2://<server>:<port>/<database>"

Can't avow that these are the last words on the subject, just the ones I
turned up googling around a bit.

- Lew
 
Reply With Quote
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      12-30-2006
Lew wrote:
> <http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/ad/cjvjt2cn.htm>
>
>
> "Syntax for a URL for the DB2 JDBC Type 2 Driver:
> jdbc:db2:database


> <http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0504vohra/index.html>
>
> "The format of the DB2 JDBC Type 4 driver [URL] is
> jdbc:db2://<server>:<port>/<database>"


The original post shows the type 4 jar file and class name.

Arne
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      12-30-2006
Arne Vajh°j wrote:
> The original post shows the type 4 jar file and class name.


The point being that perhaps use of the Type 2 syntax was not correct, eh?

- Lew

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
connecting to as400 via java servlet..not quite right Drew Java 1 02-17-2005 03:41 PM
Re: AS400 And ADOx Cor Ligthert ASP .Net 0 09-14-2004 03:50 PM
asp.net oledb command parameter error calling an as400 program Manuel Arroba ASP .Net 0 06-28-2004 09:50 AM
DB_E_BADPROPERTYVALUE error when connecting to AS400 db2 udb =?Utf-8?B?RC5TYXJhdmFuYW4=?= ASP .Net 0 06-18-2004 10:06 AM
Re: Is there an overhead in throwing an Exception instead of SQLException? John C. Bollinger Java 3 07-17-2003 06:46 AM



Advertisments