0

I try to connect to my BD This is my code

 public class JavaSQLTest {

/**
 * @param args the command line arguments
 */

public static void main(String[] args) {
    try {
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    String connectionUrl = "jdbc:sqlserver://FRANK-PC\\SQLEXPRESS" +
        "databaseName=Pendu;";
    Connection con = DriverManager.getConnection(connectionUrl);
    } catch (SQLException e) {
        System.out.println("SQL Exception: "+ e.toString());
    } catch (ClassNotFoundException cE) {
        System.out.println("Class Not Found Exception: "+ cE.toString());
    }
  }
}

I get Class Not Found Exception: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver after running....

How to connect properly on a sql server ???

Thanks Frank

FrankSharp
  • 2,552
  • 10
  • 38
  • 49
  • Check this stackoverflow [question](http://stackoverflow.com/questions/2451892/how-do-i-connect-to-a-sql-server-2008-database-in-java-with-jdbc). It is exactly what you ask. – George Karanikas Apr 08 '12 at 20:10

1 Answers1

2

You have to put the SQL Server JDBC driver library into the classpath .

aleroot
  • 71,077
  • 30
  • 176
  • 213