SQL Server JDBC Driver Tip

Article ID: 58156

I enjoy speaking at user groups mainly because I love showing people the cool programming tricks I've discovered. But even better than that is when I pick up a programming tip from one of the people I meet! On my recent trip to New Jersey, I met a man named Hugo Cantor, who gave me a tip.

There's an open-source (free) JDBC driver for Microsoft SQL Server that performs better than the one from Microsoft. And it not only works from Java, but it also works with my RPG support for JDBC drivers!

The name of the driver is jTDS, and its website claims ". . . currently the fastest production-ready JDBC driver for SQL Server and Sybase" and states that it supports the following databases:

  • Microsoft SQL Server versions 6.5, 7, 2000, and 2005
  • Sybase versions 10, 11, 12, and 15

I don't use SQL Server in my own shop, so I haven't had occasion to test these claims, but they sound pretty impressive, and they're backed up by Hugo Cantor's experience. He told me that it outperformed the Microsoft-supplied driver in his applications.

On the jTDS website, you'll find the download links and documentation.

To use jTDS with JDBCR4, download the code and put it in your CLASSPATH as you would for any other JDBC driver. Use the sample RPG code for Microsoft SQL Server but change the JDBC_ConnProp call to read as follows:

    conn = JDBC_ConnProp('net.sourceforge.jtds.jdbc.Driver'
                        :'jdbc:jtds:sqlserver://myserver.example.com:1433'
                        : prop );

For Sybase:

    conn = JDBC_ConnProp('net.sourceforge.jtds.jdbc.Driver'
                        :'jdbc:jtds:sybase://myserver.example.com:7100'
                        : prop );

The code for JDBCR4 itself doesn't need any changes to use this driver. However, if you need a copy of the JDBCR4 service program, you can find the latest version (at the time of this writing) here.

Thanks for the tip, Hugo!

Scott, I'm using your JDBCR4 service program to access a database from iseries. It's batch job we run to start the JVM. When I started using this job, it was all fine and working perfectly. But lately it has started giving error in IBM Java Procedure JNI_GETCREATEDJAVAVMS that your service program uses. The error says, "Point not set for location referenced". I'm copying a part of the dump below. I tried to figure out the error and till now no luck. Problem with this error is - it is random and no pattern whatsoever. Can you please help me with your expertise - ILE RPG/400 FORMATTED DUMP Program Status Area: Procedure Name . . . . . . . . . . . . : TCRPSJVM Program Name . . . . . . . . . . . . . : TCRPSJVM Library . . . . . . . . . . . . . . : TCOLIB Module Name. . . . . . . . . . . . . . : TCRPSJVM Program Status . . . . . . . . . . . . : 00202 The call to ended in error (C G D F). Previous Status . . . . . . . . . . . : 00000 Statement in Error . . . . . . . . . . : 00008489 RPG Routine . . . . . . . . . . . . . : JDBC_PRO Number of Parameters . . . . . . . . . : 002 Message Type . . . . . . . . . . . . . : MCH Additional Message Info . . . . . . . : 3601 Message Data . . . . . . . . . . . . . : Pointer not set for location referenced. The Job log says this - 40 12/02/09 10:03:41.573856 QJVAJNI QSYS *STMT QJVAJNI QSYS *STMT From module . . . . . . . . : QJVASWTCH From procedure . . . . . . : JNI_GetCreatedJavaVMs Statement . . . . . . . . . : 5 To module . . . . . . . . . : QJVASWTCH To procedure . . . . . . . : JNI_GetCreatedJavaVMs Statement . . . . . . . . . : 5 Message . . . . : Pointer not set for location referenced. Cause . . . . . : A pointer was used, either directly or as a basing pointer, that has not been set to an address.
No problem Scott! That was just a small contribution in light of the wealth of information that you and others like yourself volunteer to the i community. I'm greatly indebted to these forums. Many of us would be lost at sea if we only had the IBM docs. -thanks!

ProVIP Sponsors

ProVIP Sponsors