java连接到sql server 2008 express
我尝试连接到我的BD这是我的代码
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()); } } }
我得到Class Not Foundexception:运行后java.lang.ClassNotFoundException:com.microsoft.sqlserver.jdbc.SQLServerDriver ….
如何在SQL Server上正确连接???
谢谢弗兰克
您必须将SQL Server JDBC驱动程序库放入类路径中。