setMaxFieldSize (and getMaxFieldSize) - Mailing list pgsql-jdbc

From snpe
Subject setMaxFieldSize (and getMaxFieldSize)
Date
Msg-id 200304032048.55088.snpe@snpe.co.yu
Whole thread Raw
Responses fireConnectionFatalError never called
List pgsql-jdbc
Hello,
  JDBC driver have limit 8192 for maxFieldSize (AbstractJdbc1Statement.java)
Limit for 8k row is gone.in 7.1
I think that we can now define method setMaxFiledSize, too


regards
Haris Peco

Patch :

--- /u1/pgsqlcvs/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java    2003-03-08
13:11:26.000000000+0000 
+++ org/postgresql/jdbc1/AbstractJdbc1Statement.java    2003-04-03 20:31:40.000000000 +0000
@@ -21,6 +21,13 @@
 public abstract class AbstractJdbc1Statement implements BaseStatement
 {

+    // 1GB for > 7.1, 8192 before
+    final static int MAXFIELDSIZE_71 = 1073741824;
+    final static int MAXFIELDSIZE = 8192;
+
+    // max field size (set in 8192, but we can set to 1GB for > 7.1)
+    protected int maxFieldSize = 8192;
+
     // The connection who created us
     protected BaseConnection connection;

@@ -654,7 +661,7 @@
      */
     public int getMaxFieldSize() throws SQLException
     {
-        return 8192;        // We cannot change this
+        return maxFieldSize;
     }

     /*
@@ -664,9 +671,18 @@
      * @param max the new max column size limit; zero means unlimited
      * @exception SQLException if a database access error occurs
      */
-    public void setMaxFieldSize(int max) throws SQLException
+    public void setMaxFieldSize(int max) throws SQLException
     {
-        throw new PSQLException("postgresql.stat.maxfieldsize");
+        if (connection.haveMinimumServerVersion("7.1"))
+            if (max > MAXFIELDSIZE_71)
+                maxFieldSize=MAXFIELDSIZE_71;
+            else
+                maxFieldSize=max;
+        else
+            if (max > MAXFIELDSIZE)
+                maxFieldSize=MAXFIELDSIZE;
+            else
+                maxFieldSize=max;
     }

     /*


pgsql-jdbc by date:

Previous
From: "Scot P. Floess"
Date:
Subject: Re: abstract method error while using rs.beforeFirst() ???
Next
From: Ryan Christianson
Date:
Subject: fireConnectionFatalError never called