From: Alberto Molteni <albert82@tiscali.it>
To: pgsql-jdbc@postgresql.org
Subject: Problem with datestyle and driver jdbc
Date: Thu, 30 Jun 2005 22:17:37 +0200
Message-ID: <000c01c57db0$c2c6ed20$de3f0a3e@alberto0013e00> (raw)
Hi,
today I subscribed to this mailing list. I hope someone can help me with my problem.
When I try to set the datestyle of the driver postgresql-8.0-311.jdbc3.jar with this code:
connection = (Connection) DriverManager.getConnection(URL);
Statement s=connection.createStatement();
s.executeUpdate("set datestyle ='european,sql'");
s.execute("show datestyle");
s.close();
I get this error message:
org.postgresql.util.PSQLException: The server's DateStyle parameter was changed to SQL, DMY. The JDBC driver requires DateStyle to begin with ISO for correct operation.
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1302)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:264)
at DBConnection.DBConnection.<init>(DBConnection.java:57)
at GUI.Loader.setConfiguration(Loader.java:96)
at GUI.Loader.<init>(Loader.java:23)
at GUI.MainServer.main(MainServer.java:17)
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:201)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:221)
at DBConnection.DBConnection.getRecordCount(DBConnection.java:397)
at GUI.Loader.setConfiguration(Loader.java:98)
at GUI.Loader.<init>(Loader.java:23)
at GUI.MainServer.main(MainServer.java:17)
Caused by: java.io.IOException: Stream closed
at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:151)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
at org.postgresql.core.PGStream.flush(PGStream.java:493)
at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:631)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:174)
... 7 more
org.postgresql.util.PSQLException: The server's DateStyle parameter was changed to SQL, DMY. The JDBC driver requires DateStyle to begin with ISO for correct operation.
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1302)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:264)
at DBConnection.DBConnection.<init>(DBConnection.java:57)
at GUI.Loader.setConfiguration(Loader.java:96)
at GUI.Loader.<init>(Loader.java:23)
at JDoc.Server.setParameters(Server.java:214)
at JDoc.Server.<init>(Server.java:45)
at GUI.MainServer.main(MainServer.java:24)
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:201)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:221)
at DBConnection.DBConnection.getRecordCount(DBConnection.java:397)
at GUI.Loader.setConfiguration(Loader.java:98)
at GUI.Loader.<init>(Loader.java:23)
at JDoc.Server.setParameters(Server.java:214)
at JDoc.Server.<init>(Server.java:45)
at GUI.MainServer.main(MainServer.java:24)
Caused by: java.io.IOException: Stream closed
at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:151)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
at org.postgresql.core.PGStream.flush(PGStream.java:493)
at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:631)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:174)
... 9 more
org.postgresql.util.PSQLException: The server's DateStyle parameter was changed to SQL, DMY. The JDBC driver requires DateStyle to begin with ISO for correct operation.
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1302)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:264)
at DBConnection.DBConnection.<init>(DBConnection.java:57)
at JDoc.Server.main(Server.java:64)
at JDoc.Server.<init>(Server.java:46)
at GUI.MainServer.main(MainServer.java:24)
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:201)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:264)
at DBConnection.DBConnection.executeQueryInsert(DBConnection.java:291)
at JDoc.Server.main(Server.java:65)
at JDoc.Server.<init>(Server.java:46)
at GUI.MainServer.main(MainServer.java:24)
Caused by: java.io.IOException: Stream closed
at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:151)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
at org.postgresql.core.PGStream.flush(PGStream.java:493)
at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:631)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:174)
... 7 more
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:201)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:221)
at DBConnection.DBConnection.executeQueryCountLog(DBConnection.java:126)
at JDoc.Server.main(Server.java:66)
at JDoc.Server.<init>(Server.java:46)
at GUI.MainServer.main(MainServer.java:24)
Caused by: java.io.IOException: Stream closed
at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:151)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
at org.postgresql.core.PGStream.flush(PGStream.java:493)
at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:631)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:174)
... 7 more
org.postgresql.util.PSQLException: An I/O error occured while sending to the backend.
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:201)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:389)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:314)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:264)
at DBConnection.DBConnection.executeQueryInsert(DBConnection.java:291)
at JDoc.Server.main(Server.java:66)
at JDoc.Server.<init>(Server.java:46)
at GUI.MainServer.main(MainServer.java:24)
Caused by: java.io.IOException: Stream closed
at sun.nio.cs.StreamEncoder.ensureOpen(StreamEncoder.java:38)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:151)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:213)
at org.postgresql.core.PGStream.flush(PGStream.java:493)
at org.postgresql.core.v3.QueryExecutorImpl.sendSync(QueryExecutorImpl.java:631)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:174)
... 7 more
How can I change the code to have the date format as it is in the db (that is DD/MM/YYYY HH:MM:SS) and not as YYYY/MM/DD?
Thank you !
Albert
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: albert82@tiscali.it
Subject: Re: Problem with datestyle and driver jdbc
In-Reply-To: <000c01c57db0$c2c6ed20$de3f0a3e@alberto0013e00>
References: <000c01c57db0$c2c6ed20$de3f0a3e@alberto0013e00>
* 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