Apologies if this question has already been posted hundreds of times before in the past. I'm trying to setup and test my first ever jdbc connection but am having difficulty with my driver.
I'm running Microsoft SQL Server 2008 and have a copy of the jtds driver. Running the following simple test code results in an "Cannot get SQL server connection
java.sql.SQLException: No suitable driver found" error.
Where <username> & <password> have been substituted with my actual username and and password
I am running on a Windows machine and therefore updated my CLASSPATH variable to include the 'jtds-1.2.2.jar' file. I know that my database, username and password are correct as I can access this database via a JavaEE application that uses the same details on my local machine. Is anyone able to advise if my code is incorrect or is it purely that I'm missing something do with allowing my code to actually access the driver/my driver is incorrect ?
I'm still new to Java and jdbc so hoping that I've not missed something really obvious.
I just tried calling what you suggested and got a ClassNotFoundException so it must be something to do with my CLASSPATH. I think I'll need to do some further reading about how to correctly amend my CLASSPATH.
I tried placing the 'jtds-1.2.2.jar' file in the same package in my code example below but still seems to get a ClassNotFoundException. I'm a bit confused about that.