FrankSharp
FrankSharp

Reputation: 2632

java connection to sql server 2008 express

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

Upvotes: 0

Views: 3642

Answers (1)

aleroot
aleroot

Reputation: 72636

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

Upvotes: 2

Related Questions