cvs commit: village/com/workingdogs/village Value.java

[email protected] Wed, 25 Jun 2003 08:28:06 -0700 (PDT)
Newsgroups gmane.comp.db.village.devel
Message-ID <[email protected]>
jmcnally    03/06/25 08:28:06

  Modified:    com/workingdogs/village Value.java
  Log:
  Patch to Value.java handling of Blobs.  Submitted by Jetspeed developers.
  
  Revision  Changes    Path
  1.19      +12 -3     village/com/workingdogs/village/Value.java
  
  Index: Value.java
  ===================================================================
  RCS file: /home/cvs/village/com/workingdogs/village/Value.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Value.java	30 Jul 2002 23:20:51 -0000	1.18
  +++ Value.java	25 Jun 2003 15:28:05 -0000	1.19
  @@ -54,6 +54,7 @@
   package com.workingdogs.village;
   
   import java.math.BigDecimal;
  +import java.sql.Blob;
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   import java.sql.SQLException;
  @@ -67,7 +68,7 @@
   cross between a row and column and contains the information held there.
   
   @author Jon S. Stevens <A HREF="mailto:[email protected]">[email protected]</A>
  -@version $Revision: 1.18 $
  +@version $Revision: 1.19 $
   */
   public class Value
   {
  @@ -149,10 +150,14 @@
               case Types.LONGVARBINARY:
               case Types.VARBINARY:
               case Types.BINARY:
  -            case Types.BLOB:
                   valueObject = rs.getBytes (columnNumber);
                   break;
   
  +            case Types.BLOB:
  +                Blob blob = rs.getBlob(columnNumber);
  +                valueObject = blob.getBytes(1, (int) blob.length());
  +                break;
  +
               case Types.LONGVARCHAR:
               case Types.CHAR:
               case Types.VARCHAR:
  @@ -264,7 +269,11 @@
               case Types.VARBINARY:
               case Types.BINARY:
               case Types.BLOB:
  -                stmt.setBytes (stmtNumber, this.asBytes());
  +                // The following form is reported to work and be necessary for
  +                // Oracle when the blob exceeds 4k.
  +                byte[] value = this.asBytes();
  +                stmt.setBinaryStream(stmtNumber, 
  +                        new java.io.ByteArrayInputStream(value), value.length);
                   break;
   
               case Types.LONGVARCHAR: