public void testjdbc() throws Exception {
// 1、注册驱动
Class.forName("com.mysql.cj.jdbc.Driver")
// 2、获取连接
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/db01", "root", "1234")
// 3、获取sql语句执行对象
Statement statement = connection.createStatement()
// 4、执行sql语句
String sql = "insert into user(id,name,username,age,createtime,beizhu) values(100,'管理员','admin',20,'2021-03-09','备注信息')"
int count = statement.executeUpdate(sql)
System.out.println(count)
if (count > 0) {
System.out.println("添加成功")
} else {
System.out.println("添加失败")
}
statement.close()
connection.close()
}