[libpostgresql-jdbc-java] 01/04: Produce the timezone that we send to the server in the same format that we can parse. This is important for updatable ResultSets as we must be able to parse the format we produce.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_0_319
in repository libpostgresql-jdbc-java.

commit b711e796aa54e65cc5496dd74e1008f4939b16f3
Author: Kris Jurka <books at ejurka.com>
Date:   Fri Jan 5 00:34:28 2007 +0000

    Produce the timezone that we send to the server in the same format
    that we can parse.  This is important for updatable ResultSets as
    we must be able to parse the format we produce.
    
    Reported by Leon Do
---
 org/postgresql/jdbc2/TimestampUtils.java           |  4 +++-
 .../test/jdbc2/UpdateableResultTest.java           | 27 ++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/org/postgresql/jdbc2/TimestampUtils.java b/org/postgresql/jdbc2/TimestampUtils.java
index 94df030..2ab1830 100644
--- a/org/postgresql/jdbc2/TimestampUtils.java
+++ b/org/postgresql/jdbc2/TimestampUtils.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/TimestampUtils.java,v 1.12 2005/01/14 01:20:20 oliver Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/TimestampUtils.java,v 1.12.2.1 2005/02/15 08:32:16 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -379,6 +379,8 @@ public class TimestampUtils {
             sbuf.append('0');
         sbuf.append(hours);
 
+        sbuf.append(':');
+
         if (mins < 10)
             sbuf.append('0');
         sbuf.append(mins);
diff --git a/org/postgresql/test/jdbc2/UpdateableResultTest.java b/org/postgresql/test/jdbc2/UpdateableResultTest.java
index 4e47a76..51912e6 100644
--- a/org/postgresql/test/jdbc2/UpdateableResultTest.java
+++ b/org/postgresql/test/jdbc2/UpdateableResultTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2001-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java,v 1.19.2.1 2005/03/23 19:48:18 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java,v 1.19.2.2 2005/09/29 22:12:16 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -17,6 +17,7 @@ import java.io.ByteArrayInputStream;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
+import java.util.TimeZone;
 
 import org.postgresql.test.TestUtil;
 
@@ -32,7 +33,7 @@ public class UpdateableResultTest extends TestCase
     protected void setUp() throws Exception
     {
         con = TestUtil.openDB();
-        TestUtil.createTable(con, "updateable", "id int primary key, name text, notselected text", true);
+        TestUtil.createTable(con, "updateable", "id int primary key, name text, notselected text, ts timestamp with time zone", true);
         TestUtil.createTable(con, "second", "id1 int primary key, name1 text");
         TestUtil.createTable(con, "stream", "id int primary key, asi text, chr text, bin bytea");
 
@@ -186,6 +187,28 @@ public class UpdateableResultTest extends TestCase
         stmt.close();
     }
 
+    public void testUpdateTimestamp() throws SQLException
+    {
+        TimeZone origTZ = TimeZone.getDefault();
+        try {
+            // We choose a timezone which has a partial hour portion
+            // Asia/Tehran is +3:30
+            TimeZone.setDefault(TimeZone.getTimeZone("Asia/Tehran"));
+            Timestamp ts = Timestamp.valueOf("2006-11-20 16:17:18");
+
+            Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
+            ResultSet rs = stmt.executeQuery("SELECT id, ts FROM updateable");
+            rs.moveToInsertRow();
+            rs.updateInt(1,1);
+            rs.updateTimestamp(2,ts);
+            rs.insertRow();
+            rs.first();
+            assertEquals(ts, rs.getTimestamp(2));
+        } finally {
+          TimeZone.setDefault(origTZ);
+        }
+    }
+
     public void testUpdateStreams() throws SQLException, UnsupportedEncodingException
     {
         Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list