From: Michał Niklas <michal.niklas@heuthes.pl>
To: pgsql-jdbc@postgresql.org
Subject: Change of format of returned flat value after prepareThreshold
Date: Thu, 15 Oct 2015 14:18:24 +0200
Message-ID: <561F9990.10702@heuthes.pl> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
I have strange problem.
My code uses query:
SELECT (EXTRACT(EPOCH FROM timeofday()::timestamp(3))*1000) AS timestamp
I use it with prepareStatement()/executeQuery() methods and then
getString().
It worked very well with 9.3 version of JDBC driver and returns
numbers like:
1444912761727
This number is float, but when I get it via getString() method I see
it as large integer.
Now I upgraded JDBC driver to 9.4 and strange thing happened. After
sixth execution of this query I got those numbers in scientific notation:
1.444912761861E12
When I replaced prepareStatement()/executeQuery() with
createStatement()/executeQuery() getString() it always gives me large
integer.
I think preparation changed something because when I change
prepareThreshold
in connection string then change of format after value in
prepareThreshold.
Resuls of code with prepareStatement()/executeQuery() (for 9.3 I
stopped test after several secods by pressing Ctrl-C):
test JDBC
classpath=jars/postgresql-9.3-1103.jdbc41.jar:.
JDBC driver version is 'PostgreSQL 9.3 JDBC4.1 (build 1103)'; major:
9; minor: 3
column type: float8 (8)
epoch: 1444912748106; tries: 5337
epoch: 1444912750107; tries: 10648
epoch: 1444912752108; tries: 15654
^C
test JDBC
classpath=jars/postgresql-9.3-1104.jdbc41.jar:.
JDBC driver version is 'PostgreSQL 9.3 JDBC4.1 (build 1104)'; major:
9; minor: 3
column type: float8 (8)
epoch: 1444912754640; tries: 5357
epoch: 1444912756641; tries: 10571
epoch: 1444912758642; tries: 15804
epoch: 1444912760643; tries: 21079
^C
test JDBC
classpath=jars/postgresql-9.4-1202.jdbc41.jar:.
JDBC driver version is 'PostgreSQL 9.4 JDBC4.1 (build 1202)'; major:
9; minor: 4
column type: float8 (8)
last: 1444912761327; tries: 6
!!!1.444912761328E12!!!
test JDBC
classpath=jars/postgresql-9.4-1202.jdbc42.jar:.
JDBC driver version is 'PostgreSQL 9.4 JDBC4.2 (build 1202)'; major:
9; minor: 4
column type: float8 (8)
last: 1444912761460; tries: 6
!!!1.444912761461E12!!!
test JDBC
classpath=jars/postgresql-9.4-1203.jdbc41.jar:.
JDBC driver version is 'PostgreSQL 9.4 JDBC4.1 (build 1203)'; major:
9; minor: 4
column type: float8 (8)
last: 1444912761594; tries: 6
!!!1.444912761594E12!!!
test JDBC
classpath=jars/postgresql-9.4-1203.jdbc42.jar:.
JDBC driver version is 'PostgreSQL 9.4 JDBC4.2 (build 1203)'; major:
9; minor: 4
column type: float8 (8)
last: 1444912761727; tries: 6
!!!1.444912761728E12!!!
test JDBC
classpath=jars/postgresql-9.4-1204.jdbc41.jar:.
JDBC driver version is 'PostgreSQL 9.4 JDBC4.1 (build 1204)'; major:
9; minor: 4
column type: float8 (8)
last: 1444912761860; tries: 6
!!!1.444912761861E12!!!
test JDBC
classpath=jars/postgresql-9.4-1204.jdbc42.jar:.
JDBC driver version is 'PostgreSQL 9.4 JDBC4.2 (build 1204)'; major:
9; minor: 4
column type: float8 (8)
last: 1444912761995; tries: 6
!!!1.444912761995E12!!!
I think something is wrong when suddenly string representation of
result changes. I know that float number can be represented with
scientific notation, but I think that those numbers can be returned as
large integers just like it was with 9.3 drivers or just like it is
with createStatement()/executeQuery().
Now I workaround it by casting returned float to bigint.
--
Regards,
Michał Niklas
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbcAttachments:
test_float_pg.zip (application/x-zip-compressed, 2.6K) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: michal.niklas@heuthes.pl
Subject: Re: Change of format of returned flat value after prepareThreshold
In-Reply-To: <561F9990.10702@heuthes.pl>
References: <561F9990.10702@heuthes.pl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox