选择带时间戳的记录

时间:2012-05-14 09:16:02

标签: java oracle

我从数据库中选择ts:ts = Select ts from ...所以现在我的变量中有oracle.sql.TIMESTAMP。现在我需要选择此时间段的所有记录:

select * from ... where time = ts

我怎么能这样呢?

1 个答案:

答案 0 :(得分:4)

尝试PreparedStatementJavadoc):

PreparedStatement pstmt = connection.prepareStatement("select * from ... where time = ?");
pstmt.setTimestamp(1, timestamp);
ResultSet rs = pstmt.executeQuery;