Cannot connect to a Microsoft SQL Server using MS SQL JDBC Driver 1.1

Hello!

I downloaded the SQL JDBC driver 1.1 from Microsoft and got a file named sqljdbc.jar. This file has to be put in the Java classpath for java to be able to use it to connect to a MSSQL database. The problem is that, regardless of how I had put it in autoexec.bat as:

SET CLASSPATH=%CLASSPATH%;.;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu\sqljdbc.jar

or

SET CLASSPATH=%CLASSPATH%;.;"C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu\sqljdbc.jar"

or

SET CLASSPATH=%CLASSPATH%;.;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu\"sqljdbc.jar"

or

SET CLASSPATH=C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu\sqljdbc.jar

and such variations it did not work. Even after moving the file to a directory not containing empty spaces in its name and rewriting the classpath entry in autoexec.bat it did not work. The error was the typical ClassNotFoundException.

If I modify the environmental system variables in Control Panel/System, applying the same naming variations it still does not work. Even using the command:

java - classpath C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu\sqljdbc.jar program_name does not work.

I tried also using the NetBeans IDE, which does not see the com.microsoft classes autofilling. If I move the jar file to the ext directory in the java/jre/lib directory, the IDE sees it and autofills com.microsoft fields, but the command-line interpretor cannot find the jar file and the program cannot be run.

This is the connection to database sample java file that I used with little editing (my user name and database name), available from Microsoft at this address: http://support.microsoft.com/kb/313100

This question has been addressed before by another user on this forum, but the user has not been given a satisfactory answer.

Any help would be greatly appreciated. Thank you for at least reading this thread!

[2052 byte] By [domnul_mihneaa] at [2007-11-26 22:29:25]
# 1
Unless you're using a very old version of Windows, you shouldn't be using AUTOEXEC.BAT for anything.I suggest you read the Sun Java tutorial to learn how to work with classpaths and remediate any other basic skills that you've overlooked: http://java.sun.com/docs/books/tutorial/
dcmintera at 2007-7-10 11:33:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

> Even using the

> command:

> java - classpath C:\Program Files\Microsoft SQL

> Server 2005 JDBC Driver\sqljdbc_1.1\enu\sqljdbc.jar

> program_name does not work.

>

As specified that wouldn't work even if everthing else did. The path has spaces so the value has to be quoted.

>

> Any help would be greatly appreciated. Thank you for

> at least reading this thread!

Connecting has nothing to do with the class path.

Either it is finding the class or it isn't. You can't even attempt to connect until it finds the class.

If it is finding the class then everything you posted here is pointless.

jschella at 2007-7-10 11:33:24 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...