标签:
JDBC
连接数据库的三种方法:
1、Driver = new com.mysql.jdbc.Driver();
Properties user password
Deiver.connect(url,pro)
2、Driver new com.mysql.jdbc.Driver()
DriverManager.registerDriver(driver)
DriverManager.getConnection()
3、Class.forName(“com.mysql.jdbc.Driver”);
DriverManager.getConnection()
加载配置文件properties:
类.class.getResourceAsResult();
只能加载,不能写,容易出问题。
DriverManager
registerDriver
getConnection
Connection
Statement
executeQuery
ResultSet
executeUpdate
PreparedStatement
executeQuery
ResultSet
executeUpdate
CallableStatement
executeQuery
ResultSet
preparedStatement与statement
缓存 高效 防攻击
ResultSet
Next() getInt(1)或者getInt(“id”)
标签:
原文地址:http://www.cnblogs.com/core404/p/5774830.html