好忧伤,java连接sql数据库加载驱动就是失败了
以下是代码部分package com.test;
import java.sql.*;
public class Test {
public void getConnectionSqlServer() {
String driverName = "com.jdbc.sqlserver.SQLServerDriver";
String dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=db_database28";
String userName = "sa"; // 用户名
String userPwd = "123"; // 密码
Connection dbConn = null;
try {
Class.forName(driverName).newInstance();
} catch (Exception ex) {
System.out.println("驱动加载失败");
ex.printStackTrace();
}
try {
dbConn = DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("成功连接数据库!");
} catch (Exception e) {
e.printStackTrace();
} finally {