Skip to main content

ClassNotFoundException in Netbeans 6.8 w/MSSQL jdbc

3 replies [Last post]
timinator
Offline
Joined: 2005-07-26

I'm attempting my first jdbc connection using Netbeans under Win7, with MS SQL 2008. I've added the appropriate jar files to the Netbeans Library and Compile Classpath. However, I'm getting the ClassNotFoundException on the following:

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);

Module thus far is: (partial until I get around the error)

import java.sql.*;
import com.microsoft.sqlserver.jdbc.*;

public class TMSMInitialize {
public static void TMSMInitialize() {
Connection con = null;
Statement stmt = null;
ResultSet rs = null;

String connectionUrl = "jdbc:sqlserver://localhost:4242;" +
"databaseName=TMSM;user=sa;password=sa";

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con = DriverManager.getConnection(connectionUrl);
}
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
baldev
Offline
Joined: 2007-03-15

timinator,

are you able to resolve the problem. I am also getting the same problem.

If you are able to solve it, please help to sort that out.

Thanks.

baldev
Offline
Joined: 2007-03-15

Hello

Adding the sqljdbc4jar file in the Libraries folder of my project, solved problem for me.

Thanks

timinator
Offline
Joined: 2005-07-26

Yep, that did the trick for me as well. And for supporting MSSQL 2008, it has to be the sqljdbc4.jar file, not the sqljdbc.jar.