[libpostgresql-jdbc-java] 06/07: Make setObject(int, Object) aware of the Blob, Clob, and Array types when trying to infer the incoming object type.

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


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

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

commit e65bc0495c4691fac1d497eb9218ea2a1882dc9f
Author: Kris Jurka <books at ejurka.com>
Date:   Mon Oct 3 17:26:37 2005 +0000

    Make setObject(int, Object) aware of the Blob, Clob, and Array types
    when trying to infer the incoming object type.
    
    Reported by Marc Herbert.
---
 org/postgresql/jdbc2/AbstractJdbc2Statement.java |  8 +++++-
 org/postgresql/test/jdbc2/ArrayTest.java         | 31 +++++++++++++++---------
 org/postgresql/test/jdbc2/BlobTest.java          | 20 +++++++++++----
 3 files changed, 41 insertions(+), 18 deletions(-)

diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
index 66344cc..d754f54 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.68.2.8 2005/08/12 18:22:30 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.68.2.9 2005/09/29 20:40:29 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -1689,6 +1689,12 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
             setTimestamp(parameterIndex, (Timestamp)x);
         else if (x instanceof Boolean)
             setBoolean(parameterIndex, ((Boolean)x).booleanValue());
+        else if (x instanceof Blob)
+            setBlob(parameterIndex, (Blob)x);
+        else if (x instanceof Clob)
+            setClob(parameterIndex, (Clob)x);
+        else if (x instanceof Array)
+            setArray(parameterIndex, (Array)x);
         else if (x instanceof PGobject)
             setPGobject(parameterIndex, (PGobject)x);
         else
diff --git a/org/postgresql/test/jdbc2/ArrayTest.java b/org/postgresql/test/jdbc2/ArrayTest.java
index 9303e8b..d2cce7b 100644
--- a/org/postgresql/test/jdbc2/ArrayTest.java
+++ b/org/postgresql/test/jdbc2/ArrayTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/ArrayTest.java,v 1.8.2.1 2005/04/28 14:18:09 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/ArrayTest.java,v 1.8.2.2 2005/09/29 20:40:29 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -160,21 +160,28 @@ public class ArrayTest extends TestCase
 
         pstmt.setObject(1, arr, Types.ARRAY);
         pstmt.executeUpdate();
+
+        pstmt.setObject(1, arr);
+        pstmt.executeUpdate();
+
         pstmt.close();
 
         Statement select = conn.createStatement();
         ResultSet rs = select.executeQuery("SELECT intarr FROM arrtest");
-        assertTrue(rs.next());
-
-        Array result = rs.getArray(1);
-        assertEquals(Types.INTEGER, result.getBaseType());
-        assertEquals("int4", result.getBaseTypeName());
-
-        int intarr[] = (int[])result.getArray();
-        assertEquals(3, intarr.length);
-        assertEquals(1, intarr[0]);
-        assertEquals(2, intarr[1]);
-        assertEquals(3, intarr[2]);
+        int resultCount = 0;
+        while(rs.next()) {
+            resultCount++;
+            Array result = rs.getArray(1);
+            assertEquals(Types.INTEGER, result.getBaseType());
+            assertEquals("int4", result.getBaseTypeName());
+
+            int intarr[] = (int[])result.getArray();
+            assertEquals(3, intarr.length);
+            assertEquals(1, intarr[0]);
+            assertEquals(2, intarr[1]);
+            assertEquals(3, intarr[2]);
+        }
+        assertEquals(3, resultCount);
     }
 
     /**
diff --git a/org/postgresql/test/jdbc2/BlobTest.java b/org/postgresql/test/jdbc2/BlobTest.java
index 682cb2d..a50fa81 100644
--- a/org/postgresql/test/jdbc2/BlobTest.java
+++ b/org/postgresql/test/jdbc2/BlobTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/BlobTest.java,v 1.14.2.2 2005/05/08 23:17:48 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/BlobTest.java,v 1.14.2.3 2005/09/29 20:40:29 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -80,22 +80,32 @@ public class BlobTest extends TestCase
         PreparedStatement pstmt = con.prepareStatement("INSERT INTO testblob(id, lo) VALUES(?,?)");
 
         Blob blob = rs.getBlob(1);
-        pstmt.setString(1,"2");
+        pstmt.setString(1,"setObjectTypeBlob");
         pstmt.setObject(2, blob, Types.BLOB);
         assertEquals(1, pstmt.executeUpdate());
 
+	blob = rs.getBlob(1);
+        pstmt.setString(1,"setObjectBlob");
+        pstmt.setObject(2, blob);
+        assertEquals(1, pstmt.executeUpdate());
+
         blob = rs.getBlob(1);
-        pstmt.setString(1,"3");
+        pstmt.setString(1,"setBlob");
         pstmt.setBlob(2, blob);
         assertEquals(1, pstmt.executeUpdate());
 
         Clob clob = rs.getClob(1);
-        pstmt.setString(1,"4");
+        pstmt.setString(1,"setObjectTypeClob");
         pstmt.setObject(2, clob, Types.CLOB);
         assertEquals(1, pstmt.executeUpdate());
 
         clob = rs.getClob(1);
-        pstmt.setString(1,"5");
+        pstmt.setString(1,"setObjectClob");
+        pstmt.setObject(2, clob);
+        assertEquals(1, pstmt.executeUpdate());
+ 
+        clob = rs.getClob(1);
+        pstmt.setString(1,"setClob");
         pstmt.setClob(2, clob);
         assertEquals(1, pstmt.executeUpdate());
     }

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