String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://10.27.0.110:3306/health data";//health data为连接的数据库名
Connection con = null;
ResultSet res = null;
String username="xuxiaoying";
String password="123456";
public DBhelper() {
// TODO Auto-generated constructor stub
try {
// 加载MySql的驱动类
Class.forName(driver);
} catch (ClassNotFoundException e) {
System.out.println("找不到驱动程序类 ,加载驱动失败!");
e.printStackTrace();
}
try {
con= DriverManager.getConnection(url, username,password);
System.out.println("数据库连接成功!");
} catch (SQLException se) {
System.out.println("数据库连接失败!");
se.printStackTrace();
}
}