package Login;import java.sql.Connection;import java.sql.DriverManager;public class GetConn { public Connection conn=null; public Connection getConnection(){ try{ Class.forName("com.mysql.jdbc.Driver"); String url="jdbc:mysql://localhost:3306/select_courses" +"?useUnicode=true&characterEncoding=utf8"; //确定字符集 String user="root"; String passWord=""; conn=DriverManager.getConnection(url,user,passWord); if(conn!=null){ System.out.println("数据库链接成功"); } }catch(Exception e){ e.printStackTrace(); } return conn; }}