package pkg22;

import java.sql.*;

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

import javax.sql.*;

public class Test{

  private static final String DRIVER="com.microsoft.sqlserver.jdbc.SQlServerDriver";

  private static final String URL="jdbc:sqlserver://localhost:1433;databasename=";

  private static final String DATABASE_NAME ="sqlti";

  private static final String USER_NAME = "sa";
  private static final String PASSWORD = "123";

  public static void main(String []args){
  try{
  Class.forName( DRIVER );
  Connection conn =   DriverManager.getConnection(URL+DATABASE_NAME,USER_NAME,PASSWORD);
    System.out.println("数据库连接成功"+conn);
  conn.close();
    }
  catch(ClassNotFoundException e){
    System.out.println("找不到驱动"+e.getMessage());
  }
  catch(SQLException e){
    System.out.println("驱动已经加载成功,发生其他异常:"+e.getMessage());
  }
    System.out.println("哈哈哈");
  }
  }

}

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄