Postgresql 似乎转换了我使用 setTimestamp 设置的 PreparedStatement 的时间戳参数。
[我想做的事]
我想查询今天的数据。( 2016-06-30 00:00:00 ~ 2016-06-30 23:59:59)
但是,当我从 DB 得到结果时,它是 2016-06-29 15:00:00 到 2016-06-30 14:59:59 的数据。( 9 小时间隔)
我的本地时区:GMT+9 (KST)
DB timezone : UTC (GMT+0) (在表中,UTC时间存储为更新时间。我检查过。)
所以我猜是 9 小时的差距。当我将 UTC 时间戳参数传递给 postgresql 时,它从我的时间戳参数中减去了 9 小时。我想知道为什么 postgresql 这样做,以及我如何防止这种情况发生。
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd 23:59:59");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
sdf2.setTimeZone(TimeZone.getTimeZone("UTC"));
Timestamp startTime = Timestamp.valueOf(sdf.format(new Date(System.currentTimeMillis())));
Timestamp endTime = Timestamp.valueOf(sdf2.format(new Date(System.currentTimeMillis())));
PreparedStatement pstmt = conn.prepareStatement(
"SELECT * FROM some_table WHERE update_time BETWEEN ? AND …
Run Code Online (Sandbox Code Playgroud) 请帮助我.. 我有一些关于 pgAgent 的问题。
[环境]
DB : PostgreSQL 9.3
OS : Window 7
OS login ID : someid@mail.com
pgAdmin login ID : postgres
pgAgent user : postgres
pgAgent schema belongs to: postgres DB
DB that I'll treat : testDB (In Step configuration, I specified 'testDB' as Database.
Connection type is 'local'. Connection string is empty.)
DB server : local machine (my laptop computer)
Run Code Online (Sandbox Code Playgroud)
我安排了 pgAgent 作业,但无法连接数据库。
输出消息( pgAdmin>Statistics )
[Warning] Couldn't get a connection to the database (pgAgent)
Run Code Online (Sandbox Code Playgroud)
(什么数据库?有 2 …