Oracle \ Sun Java’s Interaction with MS SQL Server – Quick Prototype – Test out Connectivity along with Stored Procedure Invocation

Needed to review Oracle\Sun Java’s Interaction with MS SQL Server:

And so did the following:

  1. Downloaded Microsoft JDBC Driver. JDBC Version 3 is the latest out
    there and so downloaded that version.
  2. TextWrangler – Text Editor
  3. Created SQL Account on the DB Server. Granted minimum required access – SQL login Access – Specific Database Access – Permission to run Stored Procedure
  4. Settled on an “un-well” known TCP Port to facilitate SQL Server Remote Access.
    Opened Firewall Rules to support it.

Now that the Environment is a bit setup, took the Easy Street and combed the .Net
for HelloDB code.

But, kept getting the error pasted below:


at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at DBConnect.getConnection(
at DBConnect.getConn(
at helloDB.main(
Error Trace in getConnection() :


Threw everything at the Problem:

  • Copied Microsoft’s JDBC Driver (sqljdbc4.jar) locally
  • Tweaked the CLASSPATH environment variable. As the Client is a Unix box
  • Learned to play “nice” with BASH
    • Used Export and unset to set & reset variable
  • Tried passing in the jar files via the -cp argument list
    • java -cp ./ helloDB
    • …. Note -cp ./ means that Java should check the local directory for Jar files
  • Copied the files to OS’s native location for JDBC Jar files

Finally gave up with trying to use Microsoft JDBC Driver. Downloaded JTDS changed a couple of lines:

1) Changed the name of the “Driver” class


Microsoft’s MS SQL Server Driver:


jDTS Driver:


2) Changed JDBC base URL

Microsoft’s MS SQL Server JDBC Driver:

jDTS Driver:

jDTS worked well, and without much changes either.

And, so now it is getting late and I am getting tired.

Did what I did not want to do, copied the files to a MS Windows box.

Really no additional setup needed as the Database Connectivity Software
are self-contained in the Jar files.

Reviewed the CLASSPATH and Invoked the App. The error message read:




at$ Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DBConnect_v2000.getConnection(
at DBConnect_v2000.getConn(
at helloDB.main(
Error Trace in getConnection() :


Goggled for that error message:

and found

MS Doc clearly states that:

The class name has changed between the SQL Server 2000 JDBC driver and the SQL Server 2005 JDBC driver.  This particular class “” is the class name for the SQL Server 2000 JDBC driver.  The SQL Server 2005 JDBC driver class name is ““.
Note the change: from “microsoft.jdbc.sqlserver” to “microsoft.sqlserver.jdbc”

In addition, the SQL Server 2005 JDBC driver has a different URL prefix from the SQL Server 2000 JDBC driver.  The SQL Server 2000 JDBC driver uses an URL prefix of “jdbc:microsoft:sqlserver://”, while the SQL Server 2005 JDBC driver uses an URL prefix of “jdbc:sqlserver://“.
Note the removal of “microsoft” from the URL prefix.


So now we know what works:

Changed the name of the “Driver” class


Microsoft’s MS SQL Server Driver (v2000):



Microsoft’s MS SQL Server Driver (v2005):


please be extra careful with this one as the Class name looks the same – but the fact is that a couple of entries are inter-changed –  jdbc.sqlserver is now sqlserver.jdbc

2) Changed JDBC base URL


Microsoft’s MS SQL Server JDBC Driver (v2000):



Microsoft’s MS SQL Server JDBC Driver (v2005):


             please be a bit careful with this one as the the middle entry
             for microsoft is dropped


1) Using the JDBC Driver
2) How to Install Microsoft SQL Server JDBC
References (jDTS)

1) The jTDS Project
References (Setting the Classpath)

1) Setting the Classpath in Java
References (WebObjects)

1) WebObjects 5 : How to use Oracle JDBC Drivers

2) How do I install JDBC Driver on 10.5

References (MalcolmHardie Solutions)

1) Microsoft SQL Server and SQLEditor

References (Java for OS X Lion)

1) Java for OS X Lion Update 1
2) Java and the Mac OS
References (Java for OS X Lion – Issues )

1) Java for OS X Lion Update 1

References (Adobe)

1) Install the Java runtime (JRE) | Mac OS 10.7 Lion

References (sqljdbc.jar)

1) How to get Started with Microsoft JDBC
2) Working with a Connection

1) Running standalone Groovy Scripts

Sun/Oracle – Java – JDBC Driver – Microsoft / JDBC Driver v3.0

Playing a bit with Java JDBC Drivers this morning.

I needed a quick avenue to play with Java\JDBC Connection URL this morning.

As I did not have a simple, free JDBC-able Query tool on the machine I was using,I downloaded JaySQL from

The GUI is a bit difficult to use, but nevertheless configured it to point to my recently downloaded Microsoft’s JDBC Driver –  It is version 3.0 software and it works well.

Nevertheless, within JSQL I configured the JDBC Connection String and pointed to the DB Server.

But, the tool was just not working it was stuck and not quite working.

So next I tried my more trusted Cross-Platform Database Query Tool, DBVisualizer (

I set up the Driver Manager – pointed at the same JDBC Driver.

And, thankfully, it gave me a much better, cleaner, and revealing error message:

The error message states clearly – Java RunTime Environment (JRE) version 1.6 is not supported by the driver.  Use the sqljdbc4.jar class library…

Thus, configured the Driver Manager to use sqljdbc4.jar



Things worked better.

Now re-intimated with DBViz, I probably should continue using it.

But, to close off, returned to JaySQL…

a] Terminated the existing hung process

b] Re-initiated a new JaySQL process

c] Re-configured the Driver Manager to point to sqljdbc4.jar

And, now things worked better


  1. Microsoft & jTDS JDBC driver broken after update to 1.6.0_29

  2. System Requirements for JDBC 

Java – JDBC – Microsoft Drivers – Named Instance/ “Un-Default” Port Issues

Perplexingly, there are various issues one may run into while attempting to connect to a MS SQL Server Instance, especially the partner node of a mirrored-database.

This problem seems to be more common when MS SQL Server is running on something other than its default port 1433.

The problem is also well chronicled

  1. SQL 2005 JDBC Driver and Database Mirroring
  2. Running SQL Server ‘Default’ instance on a non-default (or non-standard) TCP port: : tips for making application connectivity work
  3. The Failover Partner connection string attribute cannot connect to a mirror partner server by using the SQL Native Client OLE DB provider and the SQL Native Client ODBC driver in a .NET Framework-based application (




a) MS SQL Server Name is EPH
b) MS SQL Server Failover Partner is EphMirr
c) Database Name is intra

( works well)

( works well)

( does not work)

works — if DBMirr is resolvable thru DNS or
on MS Windows c:\windows\system32\drivers\etc\hosts

note that is is not enough to have used cliconfg.exe to create an alias


The big problem seems to revolve around the fact that MS SQL Server does not properly resolve the port number for the partner node

Review of our various connection strings:

a) DB_CONN_STRING=jdbc:sqlserver://Eph:2060;databaseName=intra;failoverPartner=EphMirr;


  • Since the partner is listening on MS SQL Server default port of 1433, no need to specify or indicate otherwise




  • It appears that the JDBC Driver (running on the client) correctly attempts to  engage the “SQL Server Browser” service on the database server – Note that this service, by default is listening on UDP Port 1434, and so Server\ DBA\Firewall Admins should ensure that this service is set to running and service mode set to “Automatic”
  • Also note that we have “escaped” the \ (the separator between the server and alias name) and have it as \\ (two backslashes)




d) If one were try to create a SQL Client Alias


  • Note that creating a SQL Client alias is not useful — Especially, as SQL Client Alias are MS OS Specifics, and does not translate to Unix
  • Also any alias created will have to resolvable at the Network\OS level (DNS or c:\windows\system32\drivers\etc\hosts)
  • Also, note that if MS SQL Server is not listening on its default port or its a named instance then make sure that “SQL Server Browser” is running on the server

Microsoft – MSSQLServer / JDBC 3.0 Driver Released

Microsoft – MSSQLServer / JDBC 3.0 Driver Released

For those who develop\support Oracle\Sun Java based Applications that interacts with MS SQL Server, you may want to consider MS latest JDBC Driver – Microsoft SQL Server JDBC Driver 3.0. 

It is available @