成功用jdbc 实现从oracle 读取出一个时间间隔的数据
代码:
public static void test_find2() throws SQLException {
//创建连接
Connection conn = ConnTools.getConnection();
ResultSet rs = null;
//创建SQL执行工具
String sql = "select id,create_date from table_test where rownum<=10";
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()){
int id = rs.getInt("id");
Timestamp create_date = rs.getTimestamp("create_date");
System.out.println(id+":"+create_date + ":" + create_date.getClass().getName());
}
//关闭数据库连接
DbUtils.closeQuietly(conn);
}
结果:
1005:2010-02-27 10:21:19.0:java.sql.Timestamp
1006:2010-02-27 11:12:57.0:java.sql.Timestamp
1007:2010-02-27 14:28:02.0:java.sql.Timestamp
1008:2010-02-27 14:43:34.0:java.sql.Timestamp
1009:2010-02-27 14:47:53.0:java.sql.Timestamp
1010:2010-02-27 14:51:07.0:java.sql.Timestamp
1011:2010-02-27 14:52:51.0:java.sql.Timestamp
1012:2010-02-27 15:06:10.0:java.sql.Timestamp
1013:2010-02-27 15:07:47.0:java.sql.Timestamp
1014:2010-02-27 15:08:28.0:java.sql.Timestamp