真心求解、postgresql数据库使用between and的问题。。

hwjwt hwjwt 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
select sum(tc."TYPE0"),sum(tc."TYPE1"),sum(tc."TYPE2")
from "IVM_Temp"."TBL_COUNTING_2012_6_26" as tc,"IVM_Temp"."TBL_CHANNEL" as tl
where tc."CHANNELID" = tl."CHANNEL_ID"
and tl."IPCAM_IPADDRESS" = '192.168.7.101'
and tc."ENDDATETIME" between '2012-05-12 14:35:00' and '2012-08-12 14:35:00';

SQL是这样写的。。在数据库里已通过。。

但是。。

在java jdbc写的时候。

加上between ? and ? 就报错误。。如下。


org.postgresql.util.PSQLException: ERROR: operator does not exist: timestamp without time zone >= character varying
建议:No operator matches the given name and argument type(s). You might need to add explicit type casts.


部分jdbc如下。
String sql = "select sum(tc.\"TYPE0\"),sum(tc.\"TYPE1\"),sum(tc.\"TYPE2\") " +
"from \"IVM_Temp\".\"TBL_COUNTING_2012_6_26\" as tc,\"IVM_Temp\".\"TBL_CHANNEL\" as tl " +
"where tc.\"CHANNELID\" = tl.\"CHANNEL_ID\" " +
"and tl.\"IPCAM_IPADDRESS\" = ?" +
" and tc.\"ENDDATETIME\" between ? and ? ";
conn = ConnectionPostgresql.getConnection();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, ip);
ps.setString(2, begin);
ps.setString(3, end);
rs = ps.executeQuery();
while(rs.next())
{
test = new Test();
test.setTYPE0(rs.getLong(1));
test.setTYPE1(rs.getLong(2));
test.setTYPE2(rs.getLong(3));
}

就是between and 出问题。。用>和<也不行。。求解。。
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
hwjwt
MySQL 57,062 成员 56,759 内容