Change of format of returned flat value after prepareThreshold - Mailing list pgsql-jdbc
From | Michał Niklas |
---|---|
Subject | Change of format of returned flat value after prepareThreshold |
Date | |
Msg-id | 561F9990.10702@heuthes.pl Whole thread Raw |
Responses |
Re: Change of format of returned flat value after prepareThreshold
|
List | pgsql-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
Attachment
pgsql-jdbc by date: