any of sqljdbc.jar, sqljdbc4.jar, or sqljdbc41.jar, if not then please download it from here and add into CLASSPATH of your Java program.Ģ.
Check if you have downloaded JDBC Driver for Microsoft SQL Server i.e.
How to fix : .SQLServerDriverĪs I said, depending upon the individual situation solution to this error could be a little different, but this is what you should try :ġ. Horstmann to learn more about new JDBC features introduced in JDBC 3.0 and JDBC 4.0 on JDK 7. See Core Java Volume II Advanced Features by Cay S. Similarly, if you are connecting to the MSSQL database from JRE 1.5 then use sqljdbc.jar, which uses JDBC 3.0. Similarly, if you are connecting to SQL Server database from Java 1.6 then use sqljdbc4.jar, which supports JDBC 4.0 version, using this JAR in Java 1.5 will result in an Exception. If you use this JAR with a JRE version less than 1.7, you will get exceptions e.g. The latest version of JDBC is JDBC 4.1 released in Java 7, which is supported by Microsoft in sqljdbc41.jar, and you must use this JAR if you are connecting Microsoft SQL Server 2008 or 2012 from Java 1.7 or Java 1.8. This is because of different JDBC versions available in different JREs. sqljdbc.jar, sqljdbc4.jar, or sqljdbc41.jar for the MSSQL database. Sometimes you may find that there is even multiple JDBC driver JAR available for the same database e.g. mysql-connector.jar for MySQL, ojdbc6.jar for Oracle 11g database, and sqljdbc4.jar for SQL Server into your Java application's classpath. If you know a little bit of history, there are 4 types of JDBC drivers, but now days almost all databases support type 4, pure Java JDBC driver, which comes as a JAR file and is quite easy to use.Īll you need to do is include those JAR e.g. This Driver implementation class is a must for connecting to the database.
This API is present in JDK itself so you don't need any additional JAR to use this but because it has to support different database vendors, it has provided a Driver interface, which is required for database vendors like Oracle, MySQL, or Microsoft SQL Server to implement, if they want to allow their database access via JDBC.
In order to connect to any database including SQL Server from Java program, we use JDBC (Java Database Connectivity) API. Let's try to find out the real cause of : .SQLServerDriver and how to solve this nasty error that is preventing your Java program to connect to Microsoft SQL Server 2008, 2012, or even 2014 database.īy the way, if you really want to understand Java database programming from scratch, I suggest you read the book, Complete JDBC Programming course on Udemy. This course explains every important detail of Java database connectivity and JDBC with a simple example. Finding a solution becomes easy once you know how the classpath concept works in Java, a must-know for any Java developer.
Similarly, in Java, web application JDBC drivers are required to be present in the WEB-INF/lib directory or if you are running on Tomcat then tomcat/lib directory as well. BTW, in most of the cases ": .SQLServerDriver" comes because of classpath intricacies.įor example, if your Java program is using -cp or -classpath option but you added the JAR into the CLASSPATH environment variable or vice-versa. Depending upon your situation, a solution could be as simple as downloading any of sqljdbc.jar, sqljdbc4.jar, or sqljdbc41.jar, based upon the Java version you are using and adding them into CLASSPATH as set CLASSPATH = %CLASSPATH% (path to Microsoft JDBC driver) in Windows. This error comes when you try to connect to the Microsoft SQL Server database from the Java program but the required JDBC driver is not available in Classpath or driver is available in CLASSPATH but the class loader is not able to find it due to classpath intricacies.