right URL for accessing AS400 with Java

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 ;
        
edwbear1976aAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave FordSoftware Developer / Database AdministratorCommented:
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();
  connection.close();
}
catch (SQLException sqle) {
  System.err.println("Error connecting: " + sqle);
}
catch (Exception ex) {
  System.err.println("Error with input: " + ex);
}

HTH,
DaveSlash

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
edwbear1976aAuthor Commented:
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();
             conn.close();

           
            }
            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
%classpath%;C:\WINNT\java\Packages;C:\windows\system32;C:\jakarta-tomcat-5.0.28\common\lib\servlet-api;C:\jakarta-tomcat-5.0.28\common\lib\jsp-api;c:\sybase\ASEP\3pclass.zip;c:\sybase\ASEP\monclass.zip;C:\IBMJTOPEN\lib\jt400.jar;C:\IBMJTOPEN\lib\util400.jar;C:\IBMJTOPEN\lib\jt400Servlet.jar;
 
and When I use the NetBeans IDE I added the JTOPEN FILES  to my "libraries" so I got the fullpath completed
jt400.jar:
com
      ibm
            as400
                     access
                                as400JDBCDRIVER.class

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 ArchitectCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IBM System i

From novice to tech pro — start learning today.