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 PlatformDefaultImpl.java PlatformDb2Impl.java
Date Mon, 07 Apr 2003 17:59:41 GMT
thma        2003/04/07 10:59:40

  Modified:    src/java/org/apache/ojb/broker/platforms
                        PlatformDefaultImpl.java PlatformDb2Impl.java
  Log:
  add DB2 patch from VIADEE
  
  Revision  Changes    Path
  1.14      +38 -38    db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java
  
  Index: PlatformDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDefaultImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- PlatformDefaultImpl.java	2 Apr 2003 22:56:36 -0000	1.13
  +++ PlatformDefaultImpl.java	7 Apr 2003 17:59:40 -0000	1.14
  @@ -79,16 +79,16 @@
    */
   public class PlatformDefaultImpl implements Platform, JoinSyntaxTypes
   {
  -    private Logger log = LoggerFactory.getLogger(PlatformDefaultImpl.class);
  -
  -    private boolean m_batchUpdatesChecked = false;
  -    private boolean m_supportsBatchUpdates = false;
  -
  +    protected Logger log = LoggerFactory.getLogger(PlatformDefaultImpl.class);
  +    
  +    protected boolean m_batchUpdatesChecked = false;
  +    protected boolean m_supportsBatchUpdates = false;
  +    
       public boolean supportsBatchOperations()
       {
           return m_supportsBatchUpdates;
       }
  -
  +    
       public void checkForBatchSupport(Connection conn)
       {
           if (!m_batchUpdatesChecked)
  @@ -110,12 +110,12 @@
               }
           }
       }
  -
  +    
       public void afterStatementCreate(Statement stmt) throws PlatformException
       {
           //noop
       }
  -
  +    
       public void beforeStatementClose(Statement stmt, ResultSet rs) throws PlatformException
       {
           if (rs != null)
  @@ -130,12 +130,12 @@
               }
           }
       }
  -
  +    
       public void afterStatementClose(Statement stmt, ResultSet rs) throws PlatformException
       {
           //nothing
       }
  -
  +    
       /**
        * @see Platform#initializeJdbcConnection
        */
  @@ -161,7 +161,7 @@
                       else
                       {
                           log.info(
  -                                "Connection initializing: setAutoCommit jdbc-driver problems.
" + e.getMessage());
  +                        "Connection initializing: setAutoCommit jdbc-driver problems. "
+ e.getMessage());
                       }
                   }
                   break;
  @@ -179,13 +179,13 @@
                       else
                       {
                           log.info(
  -                                "Connection initializing: setAutoCommit jdbc-driver problems.
" + e.getMessage());
  +                        "Connection initializing: setAutoCommit jdbc-driver problems. "
+ e.getMessage());
                       }
                   }
                   break;
           }
       }
  -
  +    
       public void changeAutoCommitState(JdbcConnectionDescriptor jcd, Connection con, boolean
newState)
       {
           if (con == null)
  @@ -213,12 +213,12 @@
               }
           }
       }
  -
  +    
       /*
        * @see Platform#setObject(PreparedStatement, int, Object, int)
        */
       public void setObjectForStatement(PreparedStatement ps, int index, Object value, int
sqlType)
  -            throws SQLException
  +    throws SQLException
       {
           if ((value instanceof String) && (sqlType == Types.LONGVARCHAR))
           {
  @@ -230,7 +230,7 @@
               ps.setObject(index, value, sqlType);
           }
       }
  -
  +    
       /*
        * @see Platform#setNullForStatement(PreparedStatement, int, int)
        */
  @@ -238,23 +238,23 @@
       {
           ps.setNull(index, sqlType);
       }
  -
  -//    /*
  -//     * @see Platform#ignoreAutocommitExceptions()
  -//     */
  -//    public boolean ignoreAutocommitExceptions()
  -//    {
  -//        return ignoreAutocommitExceptions;
  -//    }
  -//
  -//    /*
  -//     * @see Platform#useAutoCommit()
  -//     */
  -//    public int useAutoCommit()
  -//    {
  -//        return useAutoCommit;
  -//    }
  -
  +    
  +    //    /*
  +    //     * @see Platform#ignoreAutocommitExceptions()
  +    //     */
  +    //    public boolean ignoreAutocommitExceptions()
  +    //    {
  +    //        return ignoreAutocommitExceptions;
  +    //    }
  +    //
  +    //    /*
  +    //     * @see Platform#useAutoCommit()
  +    //     */
  +    //    public int useAutoCommit()
  +    //    {
  +    //        return useAutoCommit;
  +    //    }
  +    
       /**
        * Get join syntax type for this RDBMS - one on of the constants from JoinSyntaxType
interface
        * @see Platform#getJoinSyntaxType
  @@ -263,7 +263,7 @@
       {
           return SQL92_JOIN_SYNTAX;
       }
  -
  +    
       /**
        * Override default ResultSet size determination (rs.last();rs.getRow())
        * with select count(*) operation
  @@ -273,7 +273,7 @@
       {
           return false;
       }
  -
  +    
       /**
        * Override this method to enable database based sequence generation
        */
  @@ -282,7 +282,7 @@
           /*default implementation does not support this*/
           throw new UnsupportedOperationException("This feature is not supported by this
implementation");
       }
  -
  +    
       /**
        * Override this method to enable database based sequence generation
        */
  @@ -291,7 +291,7 @@
           /*default implementation does not support this*/
           throw new UnsupportedOperationException("This feature is not supported by this
implementation");
       }
  -
  +    
       /**
        * Override this method to enable database based sequence generation
        */
  @@ -306,5 +306,5 @@
       {
           /*@todo implementation*/
           throw new UnsupportedOperationException("Not supported by this implementation");
  -    }
  +	}
   }
  
  
  
  1.4       +47 -19    db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDb2Impl.java
  
  Index: PlatformDb2Impl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/PlatformDb2Impl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PlatformDb2Impl.java	21 Sep 2002 15:54:15 -0000	1.3
  +++ PlatformDb2Impl.java	7 Apr 2003 17:59:40 -0000	1.4
  @@ -54,10 +54,11 @@
    * <http://www.apache.org/>.
    */
   
  +import java.sql.Connection;
  +import java.sql.DatabaseMetaData;
   import java.sql.PreparedStatement;
   import java.sql.SQLException;
   import java.sql.Types;
  -
   /**
    * This class extends <code>PlatformDefaultImpl</code> and defines specific
    * behavior for the DB2 platform.
  @@ -67,21 +68,48 @@
    */
   public class PlatformDb2Impl extends PlatformDefaultImpl
   {
  -	/**
  -	 * Patch provided by Avril Kotzen (hi001@webmail.co.za)
  -	 * DB2 handles TINYINT (for mapping a byte).
  -	 */
  -	public void setObjectForStatement(PreparedStatement ps, int index,
  -		Object value, int sqlType) throws SQLException
  -	{
  -		if (sqlType == Types.TINYINT)
  -		{
  -			ps.setByte(index, ((Byte)value).byteValue());
  -		}
  -		else
  -		{
  -			super.setObjectForStatement(ps, index, value, sqlType);
  -		}
  -	}
  -
  +    /**
  +     * Patch provided by Avril Kotzen (hi001@webmail.co.za)
  +     * DB2 handles TINYINT (for mapping a byte).
  +     */
  +    public void setObjectForStatement(PreparedStatement ps, int index,
  +    Object value, int sqlType) throws SQLException
  +    {
  +        if (sqlType == Types.TINYINT)
  +        {
  +            ps.setByte(index, ((Byte)value).byteValue());
  +        }
  +        else
  +        {
  +            super.setObjectForStatement(ps, index, value, sqlType);
  +        }
  +    }
  +    
  +    public void checkForBatchSupport(Connection conn)
  +    {
  +        if (!m_batchUpdatesChecked)
  +        {
  +            DatabaseMetaData meta = null;
  +            try
  +            {
  +                meta = conn.getMetaData();
  +                m_supportsBatchUpdates = meta.supportsBatchUpdates();
  +            }
  +            catch (SQLException e)
  +            {
  +                log.error("batch support check failed", e);
  +                m_supportsBatchUpdates = false;
  +            }
  +            catch(AbstractMethodError ame )
  +            {
  +                log.error(" batch support checkfailed", ame);
  +                m_supportsBatchUpdates = false;
  +            }
  +            finally
  +            {
  +                m_batchUpdatesChecked = true;
  +            }
  +        }
  +    }
  +    
   }
  
  
  

Mime
View raw message