Friday, September 7, 2007


Options for the URL used to retrieve the Connection:

1. Connect so that user is prompted for System, Userid and Password
Connection c = DriverManager.getConnection("jdbc:as400:");

2. Connect to mySystem with no default schema designated
Connection c = DriverManager.getConnection("jdbc:as400://mySystem");

3. Connect to mySys2 with myschema designated as the default schema
Connection c2 = DriverManager.getConnection("jdbc:as400://mySys2/mySchema");

4. Connect using Properties
Properties props = new Properties();
props.put("naming", "sql");
props.put("errors", "full");
Connection c = DriverManager.getConnection("jdbc:as400://mySystem",props);

5. Connect with a Userid and Password
Connection c = DriverManager.getConnection("jdbc:as400://mySystem;naming=sql;errors=full", 
                                "auser", "apassword");

When executing JDBC calls, there are two sets of rules used for searching AS400 unspecified libraries. There is a set of rules for SYSTEM naming and a set for SQL naming.

First, when SYSTEM naming is used, the options are: 1. If no libraries are specified in the libraries property of the URL and no default schema is specified then the job's library list is used.
2. When a default schema is specified on the URL, that library is searched. Libraries specified as properties have no effect. 3. When libraries are specified as properties, these are searched.

Second, when SQL naming is used:
1. If no library is specified, the default becomes the user profile name.
2. When a library is specified on the URL, it is used as the default.
3. when a library is specified as the default using properties, it becomes the default.
4. When a default library is specified on both URL and property, the one specified in the URL is used.