package 选课管理系统; import java.sql.*; public class 连接数据库 { static Connection con = null; static String datascore = "教务系统"; static String URL = "jdbc:mysql://localhost:3306/"+datascore+"?useUnicode=true&characterEncoding=utf-8&useSSL=false"; static String USER = "root"; static String PASSWORD = "root"; static { try{ Class.forName("com.mysql.jdbc.Driver"); }catch(ClassNotFoundException e) { System.out.print(e); } try{ con=DriverManager.getConnection(URL,USER,PASSWORD); }catch(SQLException e) { System.out.println(e); } } public static Connection GetConnection() { return con; } }