//使用驱动,相对路径
Class.forname("com.mysql.jdbc.Driver"); 、
//创建连接密码等//返回Connection
DriverManager. getConnectin(url,user,password);
//连接服务器的地址用户名密码和指定库
url=“jdbc:mysql://127.0.0.1:3306/xxxx”;
//设置编码的连接方式(防止乱码)
url=“jdbc:mysql://127.0.0.1:3306/xxxx?useUnicode=true&characterEncoding=UTF-8”;