加载jdbc驱动
创建字符串(jdbc URL)来指向要操作的数据源及相关属性,它定义了连接数据库时的协议、子协议和数据源名称;格式:协议:子协议:数据源名称
private static String driver="com.mysql.jdbc.Driver";
private static String url="jdbc:mysql://localhost:3306/factor2?useUnicode=true&characterEncoding=utf-8";
private static String userName="root";
private static String userPassword="123456";
Class.forName(driver);
连接数据库
conn=DriverManager.getConnection(url