right URL for accessing AS400 with Java

Posted on 2006-03-24
Last Modified: 2008-02-01
Hi there,
 I have tried this before on the JavaChannel with no answers for the right URL, I'm developing a java programm that access AS400 database, I got the right driver for that (JTOPEN), but I'm not sure if the URL 's got enough parameters(or Wheather they are right or not)
 to acces the AS400 /db2  database

this is my subUrl:

String  subUrl = "//"+Server+"/"+Database + ";Uid="+ strLoginId +";Pwd="+strPassword+";prompt=false;errors=full" ;
      String driver="";
      String protocol="jdbc:as400:";
      String url=protocol+ subUrl ;
Question by:edwbear1976a
    LVL 18

    Accepted Solution

    The following works for me:

    String system ... String username ... String password ... String query ... Connection connection = null;

    try {

      // Get a connection to the database.  Since we do not
      // provide a user id or password, a prompt will appear.
      connection = DriverManager.getConnection("jdbc:as400://" + system, username, password);
      DatabaseMetaData dbMetaData = connection.getMetaData();
    catch (SQLException sqle) {
      System.err.println("Error connecting: " + sqle);
    catch (Exception ex) {
      System.err.println("Error with input: " + ex);


    Author Comment

    Hi , and thank you for your advice

    well I just used your  way to connect and at least I got a error that tells me something

    try {
                         conn = DriverManager.getConnection("jdbc:as400://" + system, username, password);
                 DatabaseMetaData dbMetaData = conn.getMetaData();

                catch (SQLException e){System.out.println(e.getMessage());e.printStackTrace () ;}
                catch (ClassNotFoundException e){System.out.println(e.getMessage());e.printStackTrace () ;}
         return conn;


    And I get this error
    C:\jakarta-tomcat-5.0.28\work\Catalina\localhost\sisTextEditor\org\apache\jsp\ package does not exist
    I got the JTOPEN jar files in my classpath
    and When I use the NetBeans IDE I added the JTOPEN FILES  to my "libraries" so I got the fullpath completed

    but even on NetBeans I got the same error "package doesn't exist"
    I know that there must be something really silly that I'm missing like adding at the top anything like an import stament or something... should I use Upercase for that package name?
    LVL 17

    Assisted Solution

    Okay You can try in this way also. You can install DB2 ODBC Driver on your Java server. (When you install crystal reports you will automatically get install DB2 ODBC Driver). Then you can call DB2 as a normal database. And query by SQL (SQLLE). I have successfully used it for DB2 with PHP.

    BR Dushan

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    DB2 return first match 3 78
    Pointer not set for location referenced. 12 77
    IBM flash storage 840 15 45
    iSeries, AS/400 GUI 9 78
    We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
    Synchronize a new Active Directory domain with an existing Office 365 tenant
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now