下面代码实现连接SQL Server数据库

下面代码实现连接SQL Server数据库,请完成空白处代码,注意大小写,不要多填也不要少填。

import java.sql.*;

public class TestJDBC {

public static void main(String[] args) {

Connection dbConn = null;

String driverName = " (1) ";

String dbURL = "jdbc:sqlserver://127.0.0.1:1433; DatabaseName=Student";

String userName = "sa"; // 默认用户名

String userPwd = "123456"; // 密码

try {

2)                            (driverName);

dbConn = (3) (dbURL, userName, userPwd);

System.out.println("连接成功!");

}

catch (Exception e)

{

e.printStackTrace();

}

finally

{

if( (4) ){

try

{

5;

}

catch (SQLException e)

{

e.printStackTrace();

}

}

}

}

}

  1. com.microsoft.sqlserver.jdbc.SQLServerDriver
  2. Class.forName
  3. dbConn = DriverManager.getConnection(dbURL,userName,userPwd);
  4. dbConn !=null
  5. dbConn.close()

1、com.microsoft.jdbc.sqlserver.SQLServerDriver

2、Class.forName

3、DriverManager.getConnection

4、dbConn!=null

5、dbConn.close()

如有帮助,请采纳。点击我回答右上角【采纳】按钮。