JDBC简介 1、注册驱动 2、获取连接对象 3、定义sql 4、获取执行sql的对象 5、执行sql 6、处理结果 7、释放资源
public static void main(String[] args) throws Exception { //Class.forName("com.mysql.cj.jdbc.Driver"); String url = "jdbc:mysql://127.0.0.1:3306/dbname"; String username = "root"; String password = "root"; Connection conn=DriverManager.getConnection(url,username,password); Statement statement = conn.createStatement(); String sql="update username SET name='zhuhuibin'"; boolean b = statement.execute(sql); System.out.println(b); statement.close(); conn.close();