1. Load the Driver
1.1 Class.forName() | Class.forName().newInstance() | new DriverName()
1.2 实例化时自动向DriverManager注册,不需要显示调用DriverManager.registerDriver 方法
2. Connect to the DataBase
2.1 DriverManager.getConnection()
3. Execute the SQL
3.1 Connection.CreateStatement()
3.2 Statement.executeQuery()
3.3 Statement.executeUpdate()
4. Retrieve the result data
4.1 循环取得结果 while(rs.next())
5. Show the result data
5.1 将数据库中的各种类型转换为Java中的类型(getXXX)方法
6. Close
6.1 close the resultset. / close the statement / close the connection
在java里面要包含java.sql.*
以oracle为例 (导入oracle ora90 的jdbc的 clases12.jar包)
1. 在build path里面加入classes12.jar 包