日期:2014-05-16  浏览次数:20442 次

java的JDBC实现步骤
1.载入JDBC驱动程序;
2.定义连接的URL;
3.建立连接;
4.创建statement对象;
5.执行查询或更新;
6,处理结果;
7.关闭链接;
eg:
class DB(){
Class.forname("oracle.jdbc.driver.OracleDriver");
Connenction conn = DriverManager.getConnection    ("jdbc:oracle:oci8:@oradb","username","password");
Statement stmt = conn.createStatement();
ResultSet r = stmt.executeQuery("SELECT a,b,c FROM Table1");
while(r.next()){
  int i = r.getInt("a");
  String s = r.getString("b");
  float f = r.getFloat("c");
  System.out.println("Row="+ i + "" +s +"" +f);
}
r.close();
stmt.close();
conn.close();
}