pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Problem with datestyle and driver jdbc
2+ messages / 2 participants
[nested] [flat]

* Problem with datestyle and driver jdbc
@ 2005-06-30 20:17  Alberto Molteni <albert82@tiscali.it>
  0 siblings, 1 reply; 2+ messages in thread

From: Alberto Molteni @ 2005-06-30 20:17 UTC (permalink / raw)
  To: 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

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Problem with datestyle and driver jdbc
@ 2005-06-30 20:31  Kris Jurka <books@ejurka.com>
  parent: Alberto Molteni <albert82@tiscali.it>
  0 siblings, 0 replies; 2+ messages in thread

From: Kris Jurka @ 2005-06-30 20:31 UTC (permalink / raw)
  To: Alberto Molteni <albert82@tiscali.it>; +Cc: pgsql-jdbc



On Thu, 30 Jun 2005, Alberto Molteni wrote:

> 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
> 
> 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.
> 
> 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?
> 

You should do any formatting you need by retrieving a java Date or
Timestamp object and using a java.text.SimpleDateFormat to turn it into
the text representation you desire.

Kris Jurka



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2005-06-30 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-30 20:17 Problem with datestyle and driver jdbc Alberto Molteni <albert82@tiscali.it>
2005-06-30 20:31 ` Kris Jurka <books@ejurka.com>

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