db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/util/batch BatchConnection.java
Date Mon, 09 Dec 2002 08:12:48 GMT
arminw      2002/12/09 00:12:48

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        OJBBatchUpdateException.java
               src/java/org/apache/ojb/broker/util/batch
                        BatchConnection.java
  Log:
  BachConnection now use connection wrapper class,
  OJBBatchException extends now OJBRuntimeExcep.
  
  Revision  Changes    Path
  1.2       +60 -8     jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/OJBBatchUpdateException.java
  
  Index: OJBBatchUpdateException.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/OJBBatchUpdateException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OJBBatchUpdateException.java	13 Oct 2002 20:18:28 -0000	1.1
  +++ OJBBatchUpdateException.java	9 Dec 2002 08:12:48 -0000	1.2
  @@ -1,15 +1,67 @@
   package org.apache.ojb.broker.accesslayer;
   
  -import org.apache.commons.lang.exception.NestableRuntimeException;
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
  +import org.apache.ojb.broker.OJBRuntimeException;
   
  -/*
  - * Created by IntelliJ IDEA.
  - * User: Matthew Baird
  - * Date: Oct 6, 2002
  - * Time: 8:30:23 PM
  - * To change this template use Options | File Templates.
  +/**
  + *
  + * @author Matthew Baird
  + * @version $Id$
    */
  -public class OJBBatchUpdateException extends NestableRuntimeException
  +public class OJBBatchUpdateException extends OJBRuntimeException
   {
       public OJBBatchUpdateException()
       {
  
  
  
  1.4       +12 -207   jakarta-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java
  
  Index: BatchConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BatchConnection.java	3 Dec 2002 23:20:17 -0000	1.3
  +++ BatchConnection.java	9 Dec 2002 08:12:48 -0000	1.4
  @@ -55,17 +55,14 @@
    */
   
   
  -import java.sql.CallableStatement;
  +import org.apache.ojb.broker.util.WrappedConnection;
  +
   import java.sql.Connection;
  -import java.sql.DatabaseMetaData;
   import java.sql.PreparedStatement;
   import java.sql.SQLException;
  -import java.sql.SQLWarning;
  -import java.sql.Statement;
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Iterator;
  -import java.util.Map;
   
   //#ifdef JDK13
   import java.lang.reflect.Proxy;
  @@ -81,20 +78,17 @@
    * PreparedStatements into batches.
    *
    * @author Oleg Nitz (<a href="mailto:olegnitz@apache.org">olegnitz@apache.org</a>)
  + * @version $Id$
    */
  -public class BatchConnection implements Connection
  +public class BatchConnection extends WrappedConnection
   {
  -    private Connection _conn;
  -    
       private boolean _useBatchInserts;
  -
       private HashMap _statements = new HashMap();
  -
       private ArrayList _order = new ArrayList();
   
       public BatchConnection(Connection conn)
       {
  -        _conn = conn;
  +        super(conn);
       }
   
       public void setUseBatchInserts(boolean useBatchInserts)
  @@ -103,14 +97,6 @@
       }
   
       /**
  -     * Get the original Connection
  -     */
  -    public Connection getOriginalConnection()
  -    {
  -        return _conn;
  -    }
  -
  -    /**
        * Remember the order of execution
        */
       void nextExecuted(String sql)
  @@ -142,8 +128,8 @@
               if (stmt == null)
               {
                   stmt = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(),
  -                            new Class[] {PreparedStatement.class, BatchPreparedStatement.class},
  -                            new PreparedStatementInvocationHandler(this, sql));
  +                        new Class[]{PreparedStatement.class, BatchPreparedStatement.class},
  +                        new PreparedStatementInvocationHandler(this, sql));
                   _statements.put(sql, stmt);
               }
               return stmt;
  @@ -161,7 +147,7 @@
   
           if (stmt == null)
           {
  -            stmt = _conn.prepareStatement(sql);
  +            stmt = getDelegate().prepareStatement(sql);
           }
           return stmt;
       }
  @@ -175,7 +161,7 @@
   
           if (stmt == null)
           {
  -            stmt = _conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
  +            stmt = getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency);
           }
           return stmt;
       }
  @@ -183,13 +169,12 @@
       public void executeBatch() throws SQLException
       {
           BatchPreparedStatement batchStmt;
  -        
           try
           {
               for (Iterator it = _order.iterator(); it.hasNext(); )
               {
                   batchStmt = (BatchPreparedStatement) _statements.get(it.next());
  -                batchStmt.doExecute(_conn);
  +                batchStmt.doExecute(getDelegate());
               }
           }
           finally
  @@ -202,193 +187,13 @@
       public void commit() throws SQLException
       {
           executeBatch();
  -        _conn.commit();
  +        getDelegate().commit();
       }
   
       public void rollback() throws SQLException
       {
           _order.clear();
           _statements.clear();
  -        _conn.rollback();
  -    }
  -
  -    public void close() throws SQLException
  -    {
  -        _conn.close();
  -    }
  -
  -    public boolean isClosed() throws SQLException
  -    {
  -        return _conn.isClosed();
  -    }
  -
  -    public Statement createStatement() throws SQLException
  -    {
  -        return _conn.createStatement();
  +        getDelegate().rollback();
       }
  -
  -    public Statement createStatement(int resultSetType,
  -                                     int resultSetConcurrency)
  -            throws SQLException
  -    {
  -        return _conn.createStatement(resultSetType, resultSetConcurrency);
  -    }
  -
  -    public CallableStatement prepareCall(String sql) throws SQLException
  -    {
  -        return _conn.prepareCall(sql);
  -    }
  -
  -    public CallableStatement prepareCall(String sql,
  -                                         int resultSetType,
  -                                         int resultSetConcurrency)
  -            throws SQLException
  -    {
  -        return _conn.prepareCall(sql, resultSetType, resultSetConcurrency);
  -    }
  -
  -    public void clearWarnings() throws SQLException
  -    {
  -        _conn.clearWarnings();
  -    }
  -
  -    public boolean getAutoCommit() throws SQLException
  -    {
  -        return _conn.getAutoCommit();
  -    }
  -
  -    public String getCatalog() throws SQLException
  -    {
  -        return _conn.getCatalog();
  -    }
  -
  -    public DatabaseMetaData getMetaData() throws SQLException
  -    {
  -        return _conn.getMetaData();
  -    }
  -
  -    public int getTransactionIsolation() throws SQLException
  -    {
  -        return _conn.getTransactionIsolation();
  -    }
  -
  -    public Map getTypeMap() throws SQLException
  -    {
  -        return _conn.getTypeMap();
  -    }
  -
  -    public SQLWarning getWarnings() throws SQLException
  -    {
  -        return _conn.getWarnings();
  -    }
  -
  -    public boolean isReadOnly() throws SQLException
  -    {
  -        return _conn.isReadOnly();
  -    }
  -
  -    public String nativeSQL(String sql) throws SQLException
  -    {
  -        return _conn.nativeSQL(sql);
  -    }
  -
  -    public void setAutoCommit(boolean autoCommit) throws SQLException
  -    {
  -        _conn.setAutoCommit(autoCommit);
  -    }
  -
  -    public void setCatalog(String catalog) throws SQLException
  -    {
  -        _conn.setCatalog(catalog);
  -    }
  -
  -    public void setReadOnly(boolean readOnly) throws SQLException
  -    {
  -        _conn.setReadOnly(readOnly);
  -    }
  -
  -    public void setTransactionIsolation(int level) throws SQLException
  -    {
  -        _conn.setTransactionIsolation(level);
  -    }
  -
  -    public void setTypeMap(Map map) throws SQLException
  -    {
  -        _conn.setTypeMap(map);
  -    }
  -
  -
  -
  -    // ------------------- JDBC 3.0 -----------------------------------------
  -    // Will be uncommented by the build process on a JDBC 3.0 system
  -
  -//#ifdef JDBC30
  -
  -    public int getHoldability() throws SQLException {
  -        return _conn.getHoldability();
  -    }
  -
  -    public void setHoldability(int holdability) throws SQLException {
  -        _conn.setHoldability(holdability);
  -    }
  -
  -    public java.sql.Savepoint setSavepoint() throws SQLException {
  -        return _conn.setSavepoint();
  -    }
  -
  -    public java.sql.Savepoint setSavepoint(String name) throws SQLException {
  -        return _conn.setSavepoint(name);
  -    }
  -
  -    public void rollback(java.sql.Savepoint savepoint) throws SQLException {
  -        _conn.rollback(savepoint);
  -    }
  -
  -    public void releaseSavepoint(java.sql.Savepoint savepoint) throws SQLException {
  -        _conn.releaseSavepoint(savepoint);
  -    }
  -
  -    public Statement createStatement(int resultSetType,
  -                                     int resultSetConcurrency,
  -                                     int resultSetHoldability)
  -            throws SQLException {
  -        return _conn.createStatement(resultSetType, resultSetConcurrency,
  -                                     resultSetHoldability);
  -    }
  -
  -    public PreparedStatement prepareStatement(String sql, int resultSetType,
  -                                              int resultSetConcurrency,
  -                                              int resultSetHoldability)
  -        throws SQLException {
  -        return _conn.prepareStatement(sql, resultSetType,
  -                                      resultSetConcurrency,
  -                                      resultSetHoldability);
  -    }
  -
  -    public CallableStatement prepareCall(String sql, int resultSetType,
  -                                         int resultSetConcurrency,
  -                                         int resultSetHoldability)
  -            throws SQLException {
  -        return _conn.prepareCall(sql, resultSetType,
  -                                 resultSetConcurrency,
  -                                 resultSetHoldability);
  -    }
  -
  -    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
  -            throws SQLException {
  -        return _conn.prepareStatement(sql, autoGeneratedKeys);
  -    }
  -
  -    public PreparedStatement prepareStatement(String sql, int columnIndexes[])
  -            throws SQLException {
  -        return _conn.prepareStatement(sql, columnIndexes);
  -    }
  -
  -    public PreparedStatement prepareStatement(String sql, String columnNames[])
  -            throws SQLException {
  -        return _conn.prepareStatement(sql, columnNames);
  -    }
  -
  -//#endif
  -
   }
  
  
  

Mime
View raw message