|
Hi, In the following the java-code to pick up the active library-list. I use the method retrievellForm3() to have the libl, as I need it for the JDBC-calls. To use the libl for the JDBC-calls, look in my previous mail. Marc import java.util.*; /** Retrieve the current library-list, the one of the OS400-job calling the java-pgm. The library-list is retrieved from the System-property "java.library.path". The library-list is modelled as 3 Forms: Form1: List as read from the property, e.g. the librarylist in ifs- format (/QSYS.LIB/QSHELL.LIB:/QSYS.LIB/CTL.LIB:/Q....). Form2: List as OS400-format, as it can as example be used in a CHGLIBL- command. (QSHELL CTL DV51PRDA DV51PRDB DV51PRDC ). Form3: List as OS400-format without QSHELL or QJAVA. QSHELL or QJAVA are added by the java- or runjva- call, but not necessarily needed by the user applications. Création: Marc Nothum / 21.3.2003 */ public class OS400LibraryList { public String libListForm1; public String libListForm2; public String libListForm3; /** stringReplace searches a String (source) and replaces an expression (expr) by a replacement (repl). This has been written, because the java method replaceAll(...) is only available since jdk 1.4. Currently (21.3.2003), the AS400 implements jdk 1.3. @param source source-String to search in @param expr expression to be replaced @param repl replacement to write instead of the expression @return result-String */ public static String stringReplace(String source, String expr, String repl) { int exprlg = expr.length(); int repllg = repl.length(); int i = 0; int searchStart = 0; String temp = source; /* Search for the expression, starting at the beginning. If expression is found (at the position i), then replace it. Continue searching after the inserted replacement (searchStart). If no more expression is foud (indexOf returns -1), then end the loop. */ while ( (i = temp.indexOf(expr, searchStart)) != -1 ) { temp = temp.substring(0,i) + repl + temp.substring(i + exprlg); searchStart = i + repllg; } return temp; } /** Retrieve the library-list as Form1 */ public String retrievellForm1() { Properties prop = System.getProperties(); // System.out.println(prop.toString()); libListForm1 = prop.getProperty("java.library.path"); return libListForm1; } /** Retrieve the library-list as Form2 */ public String retrievellForm2() { retrievellForm1(); String temp1 = OS400LibraryList.stringReplace(libListForm1, "/QSYS.LIB/" , ""); temp1 = OS400LibraryList.stringReplace(temp1, ".LIB", ""); temp1 = OS400LibraryList.stringReplace(temp1, ":", " "); libListForm2 = temp1; return libListForm2; } /** Retrieve the library-list as Form3 */ public String retrievellForm3() { retrievellForm2(); String temp1 = OS400LibraryList.stringReplace(libListForm2, "QSHELL", "" ); temp1 = OS400LibraryList.stringReplace(temp1, "QJAVA", ""); libListForm3 = temp1; return libListForm3; } /** Use of this main for testing-purposes only */ public static void main (String args[]) throws Exception { /* String result = OS400LibraryList.stringReplace(args[0], args[1], args[2]); System.out.println(">" + result); */ OS400LibraryList os400ll = new OS400LibraryList(); System.out.println("Form1:"); System.out.println(os400ll.retrievellForm1()); System.out.println("Form2:"); System.out.println(os400ll.retrievellForm2()); System.out.println("Form3:"); System.out.println(os400ll.retrievellForm3()); } } "Anand, Rajesh" <Rajesh_Anand@xxxxxx>@midrange.com on 29/07/2005 11:03:47 Please respond to Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx> Sent by: java400-l-bounces@xxxxxxxxxxxx To: "Java Programming on and around the iSeries / AS400" <java400-l@xxxxxxxxxxxx> cc: Subject: RE: How to use LIBL in connection string. Can you please post the code. That would be very helpful. One thing that everyone has failed to reply to is the fact the very first lib specified in the libraries property is set as default lib. So my unqualified sql statement only looks for table name in this lib and doesn't search the LIBL. How puzzling?? Has anyone encountered this??? I've now installed JDK1.4.2 and had previously JDK1.2. My java pgm is called from a RPG. How does the system know which version of JVM to start as I've not specified in any parms or don't know how to in RPG. Any ideas??? Rajesh Anand Email:Rajesh_anand@xxxxxx -----Original Message----- From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Marc Nothum Sent: 29 July 2005 08:19 To: CN=Java Programming on and around the iSeries/O=AS400 Subject: RE: How to use LIBL in connection string. Hi, I use the following code to pick up the library-list, as it is in the AS400-job: Properties prop = System.getProperties(); libListForm1 = prop.getProperty("java.library.path"); This gives a list in the following format: /QSYS.LIB/QSHELL.LIB:/QSYS.LIB/CTL.LIB:/Q.... Then: The string-sequences "/QSYS.LIB/" and ".LIB" have to be removed. The ":" must be replaced by spaces. The result is a list in a format to be used in jdbc, as: "QSHELL CTL QTEMP QGPL" If needed, I can supply the code, I wrote to do the transformations. To use this libl in the jdbc-connection: Properties connProps = new Properties(); connProps.setProperty("naming", "system"); connProps.setProperty("libraries", libl); //libl is the previously created list, as "QSHELL CTL QTEMP QGPL" connProps.setProperty("user", user); connProps.setProperty("password", password); Class.forName(driver); connection = DriverManager.getConnection(dburl, connProps); Maybe this helps, Marc "Anand, Rajesh" <Rajesh_Anand@xxxxxx>@midrange.com on 28/07/2005 22:27:36 Please respond to Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx> Sent by: java400-l-bounces@xxxxxxxxxxxx To: "Java Programming on and around the iSeries / AS400" <java400-l@xxxxxxxxxxxx> cc: Subject: RE: How to use LIBL in connection string. If I use Lib names separated by commas, then will my unqualified sql will search this libl?? According to the manual, no. It will assume the first lib as the default lib for any unqualified sql statement. I want to avoid using hard coded libl all together and I want the unqualified sql statement to search the libl of the job calling the Java pgm. I think what Ashish is doing is what I want to achieve. Just thought it might be possible to specify the user libl in the connection string. maybe not!!! rgds, Rajesh Anand Email:Rajesh_anand@xxxxxx -----Original Message----- From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Franco Biaggi Sent: 28 July 2005 19:20 To: Java Programming on and around the iSeries / AS400 Subject: Re: How to use LIBL in connection string. This work fine from long time ago: DatabaseURL=jdbc:as400://10.1.1.1;transaction isolation=none;naming=system;libraries=lib1,lib2,qgpl,qtemp;block size=128;extended dynamic=true;package=MYPKG;package cache=true;package library=qgpl -- This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ -------------------------------------------------------- -- This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. -- This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l. -- This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/mailman/listinfo/java400-l or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.