![]() |
|
|
|
Using Library Lists for JDBC File Access Hey, David: How do you set your library list with JDBC and JTOpen? The JDBC documentation says that I should use system naming along with a libraries property. When I do that, it appears that the search stops on the first library. The only way I can get a select statement that uses files from more than one library is to qualify the library name. That makes it difficult to test.
-- James To be consistent with the way that the ODBC uses library names, the JTOpen 3.0 JDBC drivers take the first library that you specify and ignore the rest because the first library specified becomes the default library. To make the libraries property work the way you would expect, you have to specify a comma (,) at the beginning of the property. The extra comma tells the JDBC driver that you do not want a default library and the libraries following the comma are searched in order. You can specify the connection properties like the libraries property as part of the URL on your JDBC URL. The IBM Information Center has a complete list of the available connection properties. For example, the following connection URL will cause JDBC to search three libraries:
DriverManager.registerDriver
(new com.ibm.as400.access.AS400JDBCDriver());
conn = DriverManager.getConnection(
"jdbc:as400://mySystem;naming=system;libraries=
,lib1,lib2,lib3")
stmt = connection.createStatement();
rs = stmt.executeQuery("select * from fileinlib1
join fileinlib2…");
while (rs.next()) {
String field1 = rs.getString(1);
}
After connecting with this connection URL, the SQL select statement will search libraries lib1, lib2, and lib3 in order looking for files. -- David
|
Editors Contact the Editors |
Last Updated: 5/31/02 Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |