import java.sql.*;
public class JdbcConnect
{
@SuppressWarnings("unused")
public static void main(String[] args) {
String driveName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=student";
String userName="sa";
String userPwd="123456";
try {
Class.forName(driveName);
Connection dbconn=DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("连接成功!");
}
catch (Exception e) {
e.printStackTrace();
System.out.println("连接失败!");} } }
public class JdbcConnect
{
@SuppressWarnings("unused")
public static void main(String[] args) {
String driveName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName=student";
String userName="sa";
String userPwd="123456";
try {
Class.forName(driveName);
Connection dbconn=DriverManager.getConnection(dbURL, userName, userPwd);
System.out.println("连接成功!");
}
catch (Exception e) {
e.printStackTrace();
System.out.println("连接失败!");} } }