Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2006

Tip: Looking for answers? Try searching our database.

Connecting to db2/400 of AS400 through java throwing SQLException

Thread view: 
savita - 29 Dec 2006 12:54 GMT
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
Arne Vajhøj - 29 Dec 2006 13:01 GMT
> 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
[quoted text clipped - 5 lines]
>           {
>                           System.out.println("SQL Exception: ");

I strongly recommend you to print out e.

>           }
> *******************************************************************************
[quoted text clipped - 6 lines]
>
> 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
Lew - 30 Dec 2006 03:53 GMT
savita wrote:
>> Do I have to use other url apart from jdbc:db2:192.168.0.10

> 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.

> I use a URL syntax like:
>
[quoted text clipped - 3 lines]
>
> 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
Arne Vajhøj - 30 Dec 2006 04:22 GMT
> <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
Lew - 30 Dec 2006 06:58 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.