该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class T2
{
public static void main(String[] args)
{
try
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("成功加载SQL驱动程序");
} catch (Exception e)
{
System.out.println("找不到SQL驱动程序");
}
try
{
Connection con = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabanseName=Web", "sa", "root");
Statement stmt = con.createStatement();
System.out.println("数据库连接成功");
} catch (Exception e)
{
e.printStackTrace();
System.out.println("数据库连接失败");
}
}