java connection to sql server 2008 express

◇◆丶佛笑我妖孽 提交于 2019-12-02 18:44:49

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/10066018/java-connection-to-sql-server-2008-express

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!