You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2003/07/16 17:16:07 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/broker/platforms PlatformDefaultImpl.java PlatformDb2Impl.java Platform.java

arminw      2003/07/16 08:16:07

  Modified:    src/java/org/apache/ojb/broker/platforms
                        PlatformDefaultImpl.java PlatformDb2Impl.java
                        Platform.java
  Log:
  remove checkForBatchSupport(...) method from
  Platform interface and handle this check
  internally
  
  Revision  Changes    Path
  1.17      +42 -55    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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- PlatformDefaultImpl.java	25 Jun 2003 23:08:44 -0000	1.16
  +++ PlatformDefaultImpl.java	16 Jul 2003 15:16:06 -0000	1.17
  @@ -61,6 +61,7 @@
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   
   import java.io.StringReader;
  +import java.sql.CallableStatement;
   import java.sql.Connection;
   import java.sql.DatabaseMetaData;
   import java.sql.PreparedStatement;
  @@ -68,7 +69,6 @@
   import java.sql.SQLException;
   import java.sql.Statement;
   import java.sql.Types;
  -import java.sql.CallableStatement;
   
   /**
    * This class is a concrete implementation of <code>Platform</code>. Provides default implementations for all
  @@ -89,7 +89,13 @@
           return m_supportsBatchUpdates;
       }
   
  -    public void checkForBatchSupport(Connection conn)
  +    /**
  +     * Sets platform information for if the jdbc driver/db combo support
  +     * batch operations. Will only be checked once, then have same batch
  +     * support setting for the entire session.
  +     * @param conn
  +     */
  +    protected void checkForBatchSupport(Connection conn)
       {
           if (!m_batchUpdatesChecked)
           {
  @@ -99,9 +105,9 @@
                   meta = conn.getMetaData();
                   m_supportsBatchUpdates = meta.supportsBatchUpdates();
               }
  -            catch (SQLException e)
  +            catch (Throwable th)
               {
  -                log.error("batch support check failed", e);
  +                log.error(" batch support check failed", th);
                   m_supportsBatchUpdates = false;
               }
               finally
  @@ -136,35 +142,34 @@
           //nothing
       }
   
  -	public void beforeBatch(PreparedStatement stmt) throws PlatformException
  -	{
  -		// nothing
  -	}
  -
  -	public void addBatch(PreparedStatement stmt) throws PlatformException
  -	{
  -		// nothing
  -		try
  -		{
  -			stmt.addBatch();
  -		}
  -		catch (SQLException e)
  -		{
  -			throw new PlatformException(e.getMessage(), e);
  -		}
  -	}
  -
  -	public int[] executeBatch(PreparedStatement stmt) throws PlatformException
  -	{
  -		try
  -		{
  -			return stmt.executeBatch();
  -		}
  -		catch (SQLException e)
  -		{
  -			throw new PlatformException(e.getMessage(), e);
  -		}
  -	}
  +    public void beforeBatch(PreparedStatement stmt) throws PlatformException
  +    {
  +        // nothing
  +    }
  +
  +    public void addBatch(PreparedStatement stmt) throws PlatformException
  +    {
  +        try
  +        {
  +            stmt.addBatch();
  +        }
  +        catch (SQLException e)
  +        {
  +            throw new PlatformException("Failure while calling 'addBatch' on given Statement object", e);
  +        }
  +    }
  +
  +    public int[] executeBatch(PreparedStatement stmt) throws PlatformException
  +    {
  +        try
  +        {
  +            return stmt.executeBatch();
  +        }
  +        catch (SQLException e)
  +        {
  +            throw new PlatformException("Failure while calling 'executeBatch' on given Statement object", e);
  +        }
  +    }
   
   
       /**
  @@ -191,8 +196,7 @@
                       }
                       else
                       {
  -                        log.info(
  -                        "Connection initializing: setAutoCommit jdbc-driver problems. " + e.getMessage());
  +                        log.info("Connection initializing: setAutoCommit jdbc-driver problems. " + e.getMessage());
                       }
                   }
                   break;
  @@ -209,8 +213,7 @@
                       }
                       else
                       {
  -                        log.info(
  -                        "Connection initializing: setAutoCommit jdbc-driver problems. " + e.getMessage());
  +                        log.info("Connection initializing: setAutoCommit jdbc-driver problems. " + e.getMessage());
                       }
                   }
                   break;
  @@ -249,7 +252,7 @@
        * @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))
           {
  @@ -270,22 +273,6 @@
           ps.setNull(index, sqlType);
       }
   
  -    //    /*
  -    //     * @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
  @@ -337,7 +324,7 @@
       {
           /*@todo implementation*/
           throw new UnsupportedOperationException("Not supported by this implementation");
  -	}
  +    }
   
       public String getLastInsertIdentityQuery(String tableName)
       {
  
  
  
  1.5       +4 -33     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PlatformDb2Impl.java	7 Apr 2003 17:59:40 -0000	1.4
  +++ PlatformDb2Impl.java	16 Jul 2003 15:16:07 -0000	1.5
  @@ -54,11 +54,10 @@
    * <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.
  @@ -73,43 +72,15 @@
        * DB2 handles TINYINT (for mapping a byte).
        */
       public void setObjectForStatement(PreparedStatement ps, int index,
  -    Object value, int sqlType) throws SQLException
  +                                      Object value, int sqlType) throws SQLException
       {
           if (sqlType == Types.TINYINT)
           {
  -            ps.setByte(index, ((Byte)value).byteValue());
  +            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;
  -            }
  -        }
  -    }
  -    
   }
  
  
  
  1.16      +30 -29    db-ojb/src/java/org/apache/ojb/broker/platforms/Platform.java
  
  Index: Platform.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/platforms/Platform.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Platform.java	25 Jun 2003 23:08:44 -0000	1.15
  +++ Platform.java	16 Jul 2003 15:16:07 -0000	1.16
  @@ -56,12 +56,12 @@
   
   import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
   
  +import java.sql.CallableStatement;
   import java.sql.Connection;
   import java.sql.PreparedStatement;
   import java.sql.ResultSet;
   import java.sql.SQLException;
   import java.sql.Statement;
  -import java.sql.CallableStatement;
   
   /**
    * this interface provides callbacks that allow to perform
  @@ -91,26 +91,26 @@
        */
       public void afterStatementClose(Statement stmt, ResultSet rs) throws PlatformException;
   
  -	/**
  -	 *
  -	 * @param stmt the statement you want to batch on
  -	 * @throws PlatformException
  -	 */
  -	public void beforeBatch(PreparedStatement stmt) throws PlatformException;
  -
  -	/**
  -	 *
  -	 * @param stmt the statement you are adding to the batch
  -	 * @throws PlatformException
  -	 */
  -	public void addBatch(PreparedStatement stmt) throws PlatformException;
  -
  -	/**
  -	 *
  -	 * @param stmt the statement you want to execute the batch on
  -	 * @throws PlatformException
  -	 */
  -	public int[] executeBatch(PreparedStatement stmt) throws PlatformException;
  +    /**
  +     *
  +     * @param stmt the statement you want to batch on
  +     * @throws PlatformException
  +     */
  +    public void beforeBatch(PreparedStatement stmt) throws PlatformException;
  +
  +    /**
  +     *
  +     * @param stmt the statement you are adding to the batch
  +     * @throws PlatformException
  +     */
  +    public void addBatch(PreparedStatement stmt) throws PlatformException;
  +
  +    /**
  +     *
  +     * @param stmt the statement you want to execute the batch on
  +     * @throws PlatformException
  +     */
  +    public int[] executeBatch(PreparedStatement stmt) throws PlatformException;
   
       /**
        * callback called immediately after a JDBC Connection has been obtained
  @@ -163,13 +163,14 @@
        */
       public boolean supportsBatchOperations();
   
  -    /**
  -     * Sets platform information for if the jdbc driver/db combo support
  -     * batch operations. Will only be checked once, then have same batch
  -     * support setting for the entire session.
  -     * @param conn
  -     */
  -    public void checkForBatchSupport(Connection conn);
  +// arminw: think we can handle this internally
  +//    /**
  +//     * Sets platform information for if the jdbc driver/db combo support
  +//     * batch operations. Will only be checked once, then have same batch
  +//     * support setting for the entire session.
  +//     * @param conn
  +//     */
  +//    public void checkForBatchSupport(Connection conn);
   
       /**
        * Returns a query to create a sequence entry.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org