We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


right URL for accessing AS400 with Java

edwbear1976a asked
Medium Priority
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="com.ibm.as400.access.AS400JDBCDriver";
      String protocol="jdbc:as400:";
      String url=protocol+ subUrl ;
Watch Question

Software Developer / Database Administrator
The following works for me:

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

try {
   DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());

  // 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);


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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 {
            DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
                     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\txtEditorLauncher_jsp.java:56: package com.ibm.as400.access does not exist
            DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
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?
Dushan De SilvaTechnology Architect
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
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.