Problem with datestyle and driver jdbc

From: "Alberto Molteni" <albert82(at)tiscali(dot)it>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Problem with datestyle and driver jdbc
Date: 2005-06-30 20:17:37
Message-ID: 000c01c57db0$c2c6ed20$de3f0a3e@alberto0013e00
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-jdbc

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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message peter royal 2005-06-30 20:17:57 Re: XA support
Previous Message Dave Cramer 2005-06-30 19:08:01 Re: XA support