Before using JDBC to access data in an AS/400 database file, you need to register the JDBC driver for the IBM Toolbox for Java licensed program with the DriverManager. You can register the driver either by using a Java system property or by having the Java program register the driver:
Each virtual machine has its own method of setting system properties. For example, the Java command from the JDK uses the -D option to set system properties. To set the driver using system properties, specify the following:
"-Djdbc.drivers=com.ibm.as400.access.AS400JDBCDriver"
To explicitly load the driver, add the following to the Java program before the first JDBC call:
java.sql.DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());
The IBM Toolbox for Java JDBC driver does not require an AS400 object as an input parameter like the other IBM Toolbox for Java classes that get data from an AS/400. An AS400 object is used internally, however, to manage default user and password caching. When a connection is first made to the AS/400, the user may be prompted for user ID and password. The user has the option to save the user ID as the default user ID and add the password to the password cache. As in the other IBM Toolbox for Java functions, if the user ID and password are supplied by the Java program, the default user is not set and the password is not cached. See managing connections for information on managing connections.