Friday, April 27, 2012

WLST and DBEXTS

wls:/offline> from dbexts import dbexts
wls:/offline> d = dbexts()
Traceback (innermost last):
File "", line 1, in ?
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/dbexts.py", line 188, in __init__
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/javaos$py.class", line 256, in __getitem__
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/UserDict$py.class", line 14, in __getitem__
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/javaos$py.class", line 256, in __getitem__
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/UserDict$py.class", line 14, in __getitem__
KeyError: HOME


we need a dbexts.ini
Here it says:
"dbexts will default to looking for a file named 'dbexts.ini' in the same directory as dbexts.py but can optionally be passed a filename to the cfg attribute."


I find out many "dbexts.py", one looking promising is:
C:\bea1035\wlserver_10.3\common\wlst\modules\jython-modules\Lib\dbexts.py

I try putting a dbexts.ini in
C:\bea1035\wlserver_10.3\common\wlst\modules\jython-modules\Lib\dbexts.ini

my dbexts.ini is:
[default]
name=ora

[jdbc]
name=mysql
url=jdbc:mysql://localhost/ziclix
user=
pwd=
driver=org.gjt.mm.mysql.Driver
datahandler=com.ziclix.python.sql.handler.MySQLDataHandler

[jdbc]
name=ora
url=jdbc:oracle:thin:@localhost:1521:xe
user=DEV_SOAINFRA
pwd=DEV_SOAINFRA
driver=oracle.jdbc.driver.OracleDriver
datahandler=com.ziclix.python.sql.handler.OracleDataHandler

and still get the same "KeyError: HOME" error.

Looking in the code I find:

fn = os.path.join(os.path.split(__file__)[0], "dbexts.ini")
if not os.path.exists(fn):
fn = os.path.join(os.environ['HOME'], ".dbexts")


So I need to declare a HOME System property:
set HOME=C:\bea1035\wlserver_10.3\common\wlst\modules\jython-modules\Lib\


This time around I get:

File "", line 1, in ?
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/dbexts.py", line 189, in __init__
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/dbexts.py", line 661, in __init__
File "C:\bea1035\WLSERV~1.3\common\wlst\modules\jython-modules.jar\Lib/dbexts.py", line 664, in parse
IOError: No such file or directory: C:\bea1035\wlserver_10.3\common\wlst\modules\jython-modules\Lib\.dbexts

then I realize the file should be called ".dbexts" rather than dbexts.ini

and this time around IT WORKS!

The mystery is how to pass the dbexts.ini file location in the cfg parameter... really confusing and poorly documented...

No comments: