小编ara*_*ayo的帖子

Postgresql 似乎转换了 PreparedStatement 的时间戳参数

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)

java postgresql jdbc

5
推荐指数
1
解决办法
1879
查看次数

pgAgent 无法连接数据库:'fe_sendauth:未提供密码'(在 Windows7 中)

请帮助我.. 我有一些关于 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 …

windows-7 pgagent postgresql-9.3

2
推荐指数
1
解决办法
7784
查看次数

标签 统计

java ×1

jdbc ×1

pgagent ×1

postgresql ×1

postgresql-9.3 ×1

windows-7 ×1