Learnings

Wednesday, May 06, 2009

Function path for DB2

For CLI applications, this can be set once in db2cli.ini on the CLIENT from which connections are being initiated. The best way to do this is from inside db2 clp using a command such as:

update cli cfg for section sample using currentfunctionpath "'ORA',SYSTEM PATH,USER"

Verify by issuing a get cli cfg command.

If using JDBC, this setting will only affect Type-2 connections which internally go over CLI.
If using a Type-4 driver, you can set it directly on the datasource:
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.java.doc/doc/r0021822.htm

Else you can use:
(conn.createStatement()).execute("SET CURRENT FUNCTION PATH = 'ORA', 'SYSIBM', 'SYSFUN', USER");

You may also be able to set the property as follows:
Properties sp = new Properties();
sp.setProperty("user", args[0]);
sp.setProperty("password", args[1]);
sp.setProperty("alias", args[2]);
sp.setProperty("currentFunctionPath", "'ORA','SYSIBM','SYSFUN',USER");
DriverManager.getConnection(url, sp);

One thing to note - it is enough to set the function path to, say, 'ORA', SYSTEM PATH, USER and this will cause the keywords SYSTEM PATH and USER to get substituted automatically when the program is run.

Labels: