Hi,  I'm seeing some pretty strange behaviour with Jython and trying to connect zxJDBC to SQL Server 2000.

I've got the SP3 JDBC drivers in my classpath from :

http://www.microsoft.com/downloads/details.aspx?familyid=07287B11-0502-461A-B138-2AA54BFDC03A&displaylang=en#filelist

I'm running Jython 2.5b0 on java 1.6.0_07 under Windows XP.

I first tried connecting with zxJDBC over an ODBC bridge and everything worked fine:

def test_odbc():
    d, u, p, v = "jdbc:odbc:cpp_repo", None, None, "sun.jdbc.odbc.JdbcOdbcDriver"
    conn = zxJDBC.connect(d, u, p, v, CHARSET='utf8')
    cur = conn.cursor()
    cur.execute("select security_num from sa_mbs_pool_history")
    assert set(EXPECTED) == set([r[0] for r in cur.fetchall()])

Doing the same thing using raw JDBC also works fine:

def test_raw_java():
    '''
    This code works completely - so we know that it's possible to hit JDBC
    directly
    '''
    connstr = "jdbc:microsoft:sqlserver://localhost:1433;databaseName=CPP_REPO"
    SQLServerDriver.newInstance()
    conn = DriverManager.getConnection(connstr, 'sa', 'sa')
    stmt = conn.createStatement()
    rset = stmt.executeQuery("select * from sa_mbs_pool_history")
    actual = [r.getString('security_num') for r in RSetIter(rset)]     # RsetIter is just a python iterator wrapper around ResultSet

    assert set(EXPECTED) == actual

Using zxJDBC gives me an error though:

def test_dbapi():
    '''
    Assuming Class.forName doesn't work properly, just force the driver to load and hope
    that zxJDBC does the right thing
    '''
    SQLServerDriver.newInstance()
    url = "jdbc:microsoft:sqlserver://localhost:1433;=CPP_REPO"
    user ='sa'
    passwd='sa'
    db = zxJDBC.connect(url,user,passwd,"com.microsoft.jdbc.sqlserver.SQLServerDriver")
    c=db.cursor()

Traceback (most recent call last):
  File "C:\jython2.5b0\Lib\site-packages\nose-0.10.4-py2.5.egg\nose\case.py", line 182, in runTest
    self.test(*self.arg)
  File "C:\dev\cpprepo\jython\db\test_zxjdbc.py", line 66, in test_dbapi
    db = zxJDBC.connect(url,user,passwd,"com.microsoft.jdbc.sqlserver.SQLServerDriver")
DatabaseError: driver [com.microsoft.jdbc.sqlserver.SQLServerDriver] not found

I'm pretty sure that the problem I'm seeing with Jython is related to the invocation of Class.forName. 

Jython 2.5b0 (trunk:5540, Oct 31 2008, 13:55:41)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_07
Type "help", "copyright", "credits" or "license" for more information.
>>> Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'Class' is not defined
>>> from java.lang import Class
>>> Class.forName('sun.jdbc.odbc.JdbcOdbcDriver')
<jclass sun.jdbc.odbc.JdbcOdbcDriver 1>
>>> Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)

java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: com/microsoft/jdbc/sqlserver/SQLServerDriver
>>> import com.microsoft.jdbc.sqlserver.SQLServerDriver
>>> com.microsoft.jdbc.sqlserver.SQLServerDriver.newInstance()
com.microsoft.jdbc.sqlserver.SQLServerDriver@302e67
>>>

Any ideas?