I have this little Java project which requires that I connect to SQL Server 2005. Something I have done many times. Download the JDBC drivers from MS and copy them into the lib directory and do your shindig in the connection to get going.
But, this time things have changed and the installation instructions are worthless at best.
Here is what I did:
- Downloaded the driver files from MS for JDBC 2.0
- Unzipped to directory
- Moved jar files (there are two files sqljdbc.jar and sqljdbc4.jar) to my lib directory
- coded my connector to use Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
- Did some query code
And presto, nothing works as expected. Instead I get an exception with this in the stack trace:
"The JDBC Driver version 2.0 does not support JRE 1.4. You must upgrade JRE 1.4 to JRE 5.0 or later when using the JDBC Driver version 2.0. In some cases, you might need to recompile your application because it might not be compatible with JDK 5.0 or later. For more information, see the documentation on Sun Microsystems Web site"
Complete bogusness as neither Microsoft or Sun contain much info about how to solve this. So, head scratching starts followed by experimentation.
Come to find out I made a mistake by copying both jar files packaged in the driver to lib. They contain similar classes and the sqljdbc.jar files classes' are used if both are copied. However, the sqljdbc.jar file classes are not ment to be used with jre/jvm 1.6+ . Why noone mention this in the provided install doc is a different question.
a) Remove the not needed jar file (sqljdbc.jar) from lib directory or
b) specifically declare to use only the right one (sqljdbc4.jar)
Microsoft, please help us measly developers wasting time and state this in basic terms in your install doc.
There you have it.