Reputation: 11
I am trying to resolve problem: "java.lang.ClassNotFoundException: com.microsoft.sqlserver.jbdc.SQLServerDriver"
Actually what is my problem..whether is it a class path error or program error or by missing of library files.
//below is my code
package projektsql;
/**
*C:\ProgramFiles\MicrosoftJDBCDriver4.0forSQLServer\sqljdbc_4.0\enu\sqljdbc4
* @author m4rtin77
* intergratedSecurity=true;
*/
import java.sql.*;
import javax.swing.*;
public class ProjektSQL {
Connection conn = null;
public static Connection ConnectDB(){
try{
Class.forName("com.microsoft.sqlserver.jbdc.SQLServerDriver");
String connstring = "jdbc:sqlserver://localhost:1433;databaseName=JavaSQLProjekt;intergratedSecurity=true;";
Connection conn = DriverManager.getConnection(connstring);
JOptionPane.showMessageDialog(null, "Polaczono:");
return conn;
}catch(Exception e){
e.printStackTrace();
return null;
}
}
}
And one method in Jframe:
private void formWindowOpened(java.awt.event.WindowEvent evt) {
conn = ProjektSQL.ConnectDB();
I really dont know what is gonna out there.
Upvotes: 1
Views: 2239
Reputation: 11
Make sure you add SQL Driver Jar file to your project Library and I think you misspelled jdbc dude
Upvotes: 1