try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); connection = DriverManager.getConnection( "jdbc:sqlserver://localhost:1433;databaseName=commentsys", "sa", "bequt"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("Db连接数据库成功");