标签:定义 col host man 连接 cut cep RKE connect
本节类容
概念:
JDBC本质:
Person接口 Worker类 Person p = new Worler(); p.eat();
步骤:
JDBC快速入门 import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class JdbcCaiNiao{ public static void main(String[] args) throws Exception{ //1.导入驱动jar包 //2.注册驱动 Class.forName("com.mysql.jdbc.Driver"); //3.获取数据库连对象 Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/db3","root","password"); //4.定义sql语句 String sql = "update account set balance = 500 where id = 1"; //5.获取执行sql语句的对象 Statement Statement stmt = conn.createStatement(); //6.执行sql int count = stmt.executeUpdate(sql); //7.处理结果 System.out.println(count); //8.释放结果 stmt.close(); conn.close(); } }
标签:定义 col host man 连接 cut cep RKE connect
原文地址:https://www.cnblogs.com/cainiao-chuanqi/p/11131043.html