public class connect {
public Connection getConnect(){
try{
Class.forName("com.mysql.jdbc.Driver"); //加载驱动程序
String url = "jdbc:mysql://localhost/zuoyeshangjiaoxitong?//zuoyeshangjiaoxitong包名useUnicode=true&characterEncoding=utf-8";
String user = "root"; //用户名
String password = "123456"; //密码
Connection conn = DriverManager.getConnection(url, user, password); //连接指定数据库
//System.out.print(conn.getMetaData().getURL());
return conn;
}
catch(Exception e){
e.printStackTrace();
return null;
}
}