I cannot connect to database from my Jython program. Pure Java programs can connect, and I can connect to db from Jython but only using JDBC-ODBC bridge: "sun.jdbc.odbc.JdbcOdbcDriver". If I use native JDBC driver my program fails with "driver not found" exception.
Code:
import sys
from com.ziclix.python.sql import zxJDBC
connection1 = zxJDBC.connect('jdbc:odbc:test_odbc', 'postgres', 'postgres', 'sun.jdbc.odbc.JdbcOdbcDriver')
print "JDBC:ODBC connection set"
connection2 = zxJDBC.connect('jdbc:postgresql://127.0.0.1/test?stringtype=unspecified', 'postgres', 'postgres', 'org.postgresql.Driver')
print "JDBC native connection set"
Output:
C:\tools\pyscripts\scripts\db_examples>jython --version
Jython 2.5b1 (trunk:5903:5905, Jan 9 2009, 16:01:29)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_11
C:\tools\pyscripts\scripts\db_examples>jython pg_test.py
JDBC:ODBC connection set
Traceback (most recent call last):
File "pg_test.py", line 6, in <module>
connection2 = zxJDBC.connect('jdbc:postgresql://127.0.0.1/test?stringtype=un
specified', 'postgres', 'postgres', 'org.postgresql.Driver')
zxJDBC.DatabaseError: driver [org.postgresql.Driver] not found
I think that my CLASSPATH is set properly while native Java programs can connect to this database using native driver. I have found that all JDBC drivers have .pkc files in cachedir\packages.
What should I set to get database connection?