我从数据库中选择ts:ts = Select ts from ...
所以现在我的变量中有oracle.sql.TIMESTAMP。现在我需要选择此时间段的所有记录:
select * from ... where time = ts
我怎么能这样呢?
答案 0 :(得分:4)
尝试PreparedStatement
(Javadoc):
PreparedStatement pstmt = connection.prepareStatement("select * from ... where time = ?");
pstmt.setTimestamp(1, timestamp);
ResultSet rs = pstmt.executeQuery;