1 ?創(chuàng)建驅(qū)動
Class.forName("com.mysql.jdbc.Driver");
2 連接數(shù)據(jù)庫
?Connection ? ?conne = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/homework", "root", "123456");
3 ?通過Connection對象創(chuàng)建statement對象
Statement ?stm = conn.createStatement();?
4 執(zhí)行SQL 語句
stm.executeQuery(sql)? executeQuery 查詢? ? executeUpdate 增刪改
5 ResultSet 是一個結(jié)果集 ?耙蔑,保存了SQL語句的查詢結(jié)果, 要對她進(jìn)行遍歷