db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/platforms PlatformMsAccessImpl.java
Date Wed, 04 Jun 2003 19:02:03 GMT
thma        2003/06/04 12:02:03

  Modified:    src/java/org/apache/ojb/broker/platforms
                        PlatformMsAccessImpl.java
  Log:
  Apply a patch from Raplh Brandes that allows to write to Access Memo columns.
  Any ideas how to fix the StringBufferInputStream  warnings?
  
  Revision  Changes    Path
  1.4       +27 -17    db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsAccessImpl.java
  
  Index: PlatformMsAccessImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformMsAccessImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PlatformMsAccessImpl.java	26 Jan 2003 12:44:37 -0000	1.3
  +++ PlatformMsAccessImpl.java	4 Jun 2003 19:02:03 -0000	1.4
  @@ -1,5 +1,4 @@
   package org.apache.ojb.broker.platforms;
  -
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  @@ -53,7 +52,8 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
  +import java.io.StringBufferInputStream;
  +import java.io.InputStream;
   import java.math.BigDecimal;
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
  @@ -62,14 +62,12 @@
   import java.sql.Types;
   
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  -
   /**
  - * @version 	1.0
  - * @author 	jakob bräuchi
  + * @version         1.0
  + * @author         jakob bräuchi
    */
   public class PlatformMsAccessImpl extends PlatformDefaultImpl
   {
  -
       /**
        * @see Platform#setObjectForStatement(PreparedStatement, int, Object, int)
        */
  @@ -94,20 +92,33 @@
                   super.setObjectForStatement(ps, index, value, sqlType);
               }
           }
  +        // patch by Ralph Brandes to allow writing to memo fields
  +        else if (sqlType == Types.LONGVARCHAR)
  +        {
  +            if (value instanceof String)
  +            {
  +                String s = (String) value;
  +                // ps.setCharacterStream(index, new StringReader(s), s.length());
  +                // for MSACCESS :
  +                
  +                InputStream ins = new StringBufferInputStream(s);
  +                
  +                ps.setAsciiStream(index, ins, s.length());
  +            }
  +            else
  +            {
  +                super.setObjectForStatement(ps, index, value, sqlType);
  +            }
  +        }
           else
           {
               super.setObjectForStatement(ps, index, value, sqlType);
           }
       }
   
  -    /*
  -     * @see Platform#ignoreAutocommitExceptions()
  +    /**
  +     * @see Platform#beforeStatementClose(Statement stmt, ResultSet rs)
        */
  -    public boolean ignoreAutocommitExceptions()
  -    {
  -        return true;
  -    }
  -
       public void beforeStatementClose(Statement stmt, ResultSet rs) throws PlatformException
       {
           if (rs != null)
  @@ -118,10 +129,9 @@
               }
               catch (SQLException e)
               {
  -            	LoggerFactory.getDefaultLogger().warn("Resultset closing failed (can be ignored
for MsAccess)");
  +                LoggerFactory.getDefaultLogger().warn(
  +                    "Resultset closing failed (can be ignored for MsAccess)");
               }
           }
       }
  -
  -
  -}
  +}
  \ No newline at end of file
  
  
  

Mime
View raw message