You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Mathieu Frenette <ma...@freeborders.com> on 2002/04/02 15:49:04 UTC

RE: Oracle CLOBs

+1 for applying the patch.  I have the same problem here.  I had to remove
all blob-related columns from my XML DB schema, so that those columns get
ignored (but this is not a good solution either! ;-)

-- Mat

-----Original Message-----
From: dlr@despot.finemaltcoding.com
[mailto:dlr@despot.finemaltcoding.com]On Behalf Of Daniel Rall
Sent: March 29, 2002 2:53 AM
To: village-dev@share.whichever.com
Cc: turbine-dev@jakarta.apache.org
Subject: Re: Oracle CLOBs


"Davide Baroncelli" <ba...@yahoo.com> writes:

>> Is there a way to use the village api to select CLOBs from an Oracle DB?
>> When I try I get a....
>> java.lang.NumberFormatException: 4294967295
> Oddily, I ran into this problem too, today. This was using torque, and
> trying to use a table with a column of BLOB type on an Oracle 8i DB. This
> doesn't happen to be a Village or Oracle-related problem, but a JDK
related
> one. The problem is that ResultSetMetaData interface has an int return
value
> for the getPrecision() method, which is not large enough to store the
value
> returned by oracle when the class asks the driver the precision of the
> column. There are various messages on the OTN reporting that, and you can
> vote this bug in the java developer connection if you want the thing
solved:
> http://developer.java.sun.com/developer/bugParade/bugs/4625851.html
> Village fails to do what is supposed to do, because it doesn't wrap the
call
> to
>         this.precision = rsmd.getPrecision (columnNumber);
> in a try-catch in the Column.populate() method. I know this is ugly, but
in
> order to gain robustness towards database independence I think the call
> should be changed to
>
> try {
>     this.precision = rsmd.getPrecision (columnNumber);
> }
> catch ( NumberFormatException nfe ) {
>     // This may happen if the precision is too large for an int
>     // see bug #4625851 in the JDC
> (http://developer.java.sun.com/developer/bugParade/bugs/4625851.html)
>     this.precision = Integer.MAX_VALUE;
> }
>
> But except this problem, I see a greater problem, with blobs and clobs:
> Village seems to treat them in a non particular way, trying to set them to
> database columns as setString! This won't work in Oracle as, as far as I
> know, one has to use Streaming to write into blob columns. See
>
http://download-uk.oracle.com/otndoc/oracle9i/901_doc/java.901/a90211/oralob
> .htm#1000888 for reference. In fact, trying to set in a blob column a 128
Kb
> image causes oracle to report an error, saying the passed data is too
large.
>
> In the meanwhile, you can maybe use LONG instead of CLOB: they use up to
2Gb
> instead of 4 and the return value does not cause the Integer.parseInt to
> explode.

Davide, I totally I agree.  I've hit this problem myself.  Since it
will be a while before Sun fixes this bug and rolls out a new version,
I recommend integration of the following patch:

Index: Column.java
===================================================================
RCS file: /home/cvspublic/village/com/workingdogs/village/Column.java,v
retrieving revision 1.8
diff -u -u -r1.8 Column.java
--- Column.java	2001/09/10 20:35:32	1.8
+++ Column.java	2002/03/29 07:51:19
@@ -151,7 +151,17 @@
         this.readOnly = rsmd.isReadOnly (columnNumber);
         this.searchable = rsmd.isSearchable (columnNumber);
         this.scale = rsmd.getScale (columnNumber);
-        this.precision = rsmd.getPrecision (columnNumber);
+        try
+        {
+            this.precision = rsmd.getPrecision (columnNumber);
+        }
+        catch (NumberFormatException assumedTooLarge)
+        {
+            // This may happen if the precision is too large for an
+            // int, with column types such as MySQL BIGINT, Oracle
+            // BLOB, etc..  See bug #4625851 at the JDC for details.
+            this.precision = Integer.MAX_VALUE;
+        }
         this.length = rsmd.getColumnDisplaySize (columnNumber);
     }


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>