jdbc的链接
//1. 导入数据库驱动
Class.forName("com.mysql.jdbc.Driver");
//2.获取连接对象
try{
String url = "jdbc:mysql://localhost:3306/student?useSSL=false";// 获取数据库连接地址
String username = "root";
String password ="123456";
Connection conn = DriverManager.getConnection(url,username,password);
Statement stmt = conn.createStatement();
// 执行sql 语句
stmt.execute("insert into t_user (id,user_name) values (12,"测试"));
// 3. 关闭连接 释放内存资源 节约性能
stmt.close();
conn.close();
}catch(Exception e){
}