db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/java/org/apache/ojb/broker/ant DBUtility.java
Date Sat, 22 May 2004 11:24:51 GMT
brj         2004/05/22 04:24:51

  Modified:    src/java/org/apache/ojb/broker/util/batch
                        BatchConnection.java
               src/java/org/apache/ojb/broker/accesslayer
                        StatementManager.java
               src/java/org/apache/ojb/broker/util/sequence
                        SequenceManagerMySQLImpl.java
               src/java/org/apache/ojb/broker/ant DBUtility.java
  Log:
  removed unnecessary throws clauses
  
  Revision  Changes    Path
  1.20      +37 -82    db-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java
  
  Index: BatchConnection.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- BatchConnection.java	4 Apr 2004 23:53:37 -0000	1.19
  +++ BatchConnection.java	22 May 2004 11:24:50 -0000	1.20
  @@ -15,13 +15,11 @@
    * limitations under the License.
    */
   
  -
  -import org.apache.ojb.broker.util.WrappedConnection;
  -
  +import java.lang.reflect.Proxy;
   import java.sql.Connection;
   import java.sql.PreparedStatement;
  -import java.sql.Statement;
   import java.sql.SQLException;
  +import java.sql.Statement;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.HashMap;
  @@ -29,21 +27,13 @@
   import java.util.Iterator;
   import java.util.List;
   
  -//#ifdef JDK13
  -import java.lang.reflect.Proxy;
  -//#else
  -/*
  -import com.develop.java.lang.reflect.Proxy;
  -*/
  -//#endif
  -
   import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.broker.platforms.PlatformException;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
  -import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
   import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
  +import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
  +import org.apache.ojb.broker.util.WrappedConnection;
   
   /**
    * The implementation of {@link java.sql.Connection} which
  @@ -71,12 +61,12 @@
       private HashSet _dontInsert;
       private HashSet _touched = new HashSet();
       private int count = 0;
  -	private JdbcConnectionDescriptor m_jcd;
  +    private JdbcConnectionDescriptor m_jcd;
   
       public BatchConnection(Connection conn, PersistenceBroker broker)
       {
           super(conn);
  -		m_jcd = broker.serviceConnectionManager().getConnectionDescriptor();
  +        m_jcd = broker.serviceConnectionManager().getConnectionDescriptor();
           _fkInfo = (HashMap) _pbkeyToFKInfo.get(broker.getPBKey());
           if (_fkInfo != null)
           {
  @@ -85,30 +75,26 @@
   
           DescriptorRepository repos = broker.getDescriptorRepository();
           _fkInfo = new HashMap();
  -        for (Iterator it = repos.iterator(); it.hasNext(); )
  +        for (Iterator it = repos.iterator(); it.hasNext();)
           {
               ClassDescriptor desc = (ClassDescriptor) it.next();
               List ordList = desc.getObjectReferenceDescriptors();
               if (!ordList.isEmpty())
               {
                   HashSet fkTables = getFKTablesFor(desc.getFullTableName());
  -                for (Iterator it2 = ordList.iterator(); it2.hasNext(); )
  +                for (Iterator it2 = ordList.iterator(); it2.hasNext();)
                   {
  -                    ObjectReferenceDescriptor ord =
  -                            (ObjectReferenceDescriptor) it2.next();
  -                    ClassDescriptor oneDesc =
  -                            repos.getDescriptorFor(ord.getItemClass());
  +                    ObjectReferenceDescriptor ord = (ObjectReferenceDescriptor) it2.next();
  +                    ClassDescriptor oneDesc = repos.getDescriptorFor(ord.getItemClass());
                       fkTables.addAll(getFullTableNames(oneDesc, repos));
                   }
               }
   
               List codList = desc.getCollectionDescriptors();
  -            for (Iterator it2 = codList.iterator(); it2.hasNext(); )
  +            for (Iterator it2 = codList.iterator(); it2.hasNext();)
               {
  -                CollectionDescriptor cod =
  -                        (CollectionDescriptor) it2.next();
  -                ClassDescriptor manyDesc =
  -                        repos.getDescriptorFor(cod.getItemClass());
  +                CollectionDescriptor cod = (CollectionDescriptor) it2.next();
  +                ClassDescriptor manyDesc = repos.getDescriptorFor(cod.getItemClass());
                   if (cod.isMtoNRelation())
                   {
                       HashSet fkTables = getFKTablesFor(cod.getIndirectionTable());
  @@ -118,7 +104,7 @@
                   else
                   {
                       HashSet manyTableNames = getFullTableNames(manyDesc, repos);
  -                    for (Iterator it3 = manyTableNames.iterator(); it3.hasNext(); )
  +                    for (Iterator it3 = manyTableNames.iterator(); it3.hasNext();)
                       {
                           HashSet fkTables = getFKTablesFor((String) it3.next());
                           fkTables.addAll(getFullTableNames(desc, repos));
  @@ -148,10 +134,11 @@
           Collection extents = desc.getExtentClasses();
   
           tableName = desc.getFullTableName();
  -        if (tableName != null) {
  +        if (tableName != null)
  +        {
               tableNamesSet.add(tableName);
           }
  -        for (Iterator it = extents.iterator(); it.hasNext(); )
  +        for (Iterator it = extents.iterator(); it.hasNext();)
           {
               Class extClass = (Class) it.next();
               ClassDescriptor extDesc = repos.getDescriptorFor(extClass);
  @@ -182,9 +169,8 @@
           }
   
           String sqlCmd = sql.substring(0, 7);
  -        String rest = sql.substring(
  -                sqlCmd.equals("UPDATE ") ? 7    // "UPDATE "
  -                                         : 12); // "INSERT INTO " or "DELETE FROM "
  +        String rest = sql.substring(sqlCmd.equals("UPDATE ") ? 7 // "UPDATE "
  +                : 12); // "INSERT INTO " or "DELETE FROM "
           String tableName = rest.substring(0, rest.indexOf(' '));
           HashSet fkTables = (HashSet) _fkInfo.get(tableName);
   
  @@ -206,7 +192,8 @@
                   executeBatch();
               }
           }
  -        else //if (sqlCmd.equals("DELETE ") || sqlCmd.equals("UPDATE "))
  +        else
  +        //if (sqlCmd.equals("DELETE ") || sqlCmd.equals("UPDATE "))
           {
               // We process UPDATEs in the same way as DELETEs
               // because setting FK to NULL in UPDATE is equivalent
  @@ -257,20 +244,19 @@
        * If UPDATE, INSERT or DELETE, return BatchPreparedStatement,
        * otherwise return null.
        */
  -    private PreparedStatement prepareBatchStatement(String sql) throws PlatformException
  -	{
  +    private PreparedStatement prepareBatchStatement(String sql)
  +    {
           String sqlCmd = sql.substring(0, 7);
   
  -        if (sqlCmd.equals("UPDATE ") || sqlCmd.equals("DELETE ")
  -                || (_useBatchInserts && sqlCmd.equals("INSERT ")))
  +        if (sqlCmd.equals("UPDATE ") || sqlCmd.equals("DELETE ") || (_useBatchInserts &&
sqlCmd.equals("INSERT ")))
           {
               PreparedStatement stmt = (PreparedStatement) _statements.get(sql);
               if (stmt == null)
               {
                   // [olegnitz] for JDK 1.2 we need to list both PreparedStatement and Statement
                   // interfaces, otherwise proxy.jar works incorrectly
  -                stmt = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(),
  -                        new Class[]{PreparedStatement.class, Statement.class, BatchPreparedStatement.class},
  +                stmt = (PreparedStatement) Proxy.newProxyInstance(getClass().getClassLoader(),
new Class[]{
  +                        PreparedStatement.class, Statement.class, BatchPreparedStatement.class},
                           new PreparedStatementInvocationHandler(this, sql, m_jcd));
                   _statements.put(sql, stmt);
               }
  @@ -282,56 +268,25 @@
           }
       }
   
  -    public PreparedStatement prepareStatement(String sql)
  -            throws SQLException
  +    public PreparedStatement prepareStatement(String sql) throws SQLException
       {
  -		PreparedStatement stmt = null;
  -		try
  -		{
  -			stmt = prepareBatchStatement(sql);
  -		}
  -		catch (PlatformException e)
  -		{
  -			if (e.getCause() instanceof SQLException)
  -			{
  -				throw (SQLException)e.getCause();
  -			}
  -			else
  -			{
  -				throw new SQLException(e.getMessage());
  -			}
  -		}
  +        PreparedStatement stmt = null;
  +        stmt = prepareBatchStatement(sql);
   
  -		if (stmt == null)
  +        if (stmt == null)
           {
               stmt = getDelegate().prepareStatement(sql);
           }
           return stmt;
       }
   
  -    public PreparedStatement prepareStatement(String sql,
  -                                              int resultSetType,
  -                                              int resultSetConcurrency)
  +    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
               throws SQLException
       {
  -		PreparedStatement stmt = null;
  -		try
  -		{
  -			stmt = prepareBatchStatement(sql);
  -		}
  -		catch (PlatformException e)
  -		{
  -			if (e.getCause() instanceof SQLException)
  -			{
  -				throw (SQLException)e.getCause();
  -			}
  -			else
  -			{
  -				throw new SQLException(e.getMessage());
  -			}
  -		}
  +        PreparedStatement stmt = null;
  +        stmt = prepareBatchStatement(sql);
   
  -		if (stmt == null)
  +        if (stmt == null)
           {
               stmt = getDelegate().prepareStatement(sql, resultSetType, resultSetConcurrency);
           }
  @@ -345,7 +300,7 @@
   
           try
           {
  -            for (Iterator it = _order.iterator(); it.hasNext(); )
  +            for (Iterator it = _order.iterator(); it.hasNext();)
               {
                   batchStmt = (BatchPreparedStatement) _statements.get(it.next());
                   batchStmt.doExecute(conn);
  @@ -405,4 +360,4 @@
           clearBatch();
           getDelegate().rollback();
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.47      +4 -4      db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java
  
  Index: StatementManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- StatementManager.java	4 Apr 2004 23:53:31 -0000	1.46
  +++ StatementManager.java	22 May 2004 11:24:50 -0000	1.47
  @@ -255,7 +255,7 @@
        * @param crit the Criteria containing the parameter
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(PreparedStatement stmt, int index, NullCriteria crit) throws
SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, NullCriteria crit)
       {
           return index;
       }
  @@ -267,7 +267,7 @@
        * @param crit , the Criteria containing the parameter
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(PreparedStatement stmt, int index, FieldCriteria crit) throws
SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, FieldCriteria crit)
       {
           return index;
       }
  @@ -279,7 +279,7 @@
        * @param crit the Criteria containing the parameter
        * @return next index for PreparedStatement
        */
  -    private int bindStatement(PreparedStatement stmt, int index, SqlCriteria crit) throws
SQLException
  +    private int bindStatement(PreparedStatement stmt, int index, SqlCriteria crit)
       {
           return index;
       }
  
  
  
  1.21      +6 -6      db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerMySQLImpl.java
  
  Index: SequenceManagerMySQLImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/sequence/SequenceManagerMySQLImpl.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- SequenceManagerMySQLImpl.java	9 Apr 2004 13:22:30 -0000	1.20
  +++ SequenceManagerMySQLImpl.java	22 May 2004 11:24:51 -0000	1.21
  @@ -91,7 +91,7 @@
        * to create the sequence is:
        * CREATE SEQUENCE MY_SCHEMA.SQ_MY_TABLE_MY_FIELD
        */
  -    private synchronized int getNextId(FieldDescriptor field) throws SequenceManagerException
  +    private synchronized int getNextId(FieldDescriptor field) 
       {
           return 0;
       }
  @@ -100,7 +100,7 @@
        * returns a unique int for class clazz and field fieldName.
        * the returned uid is unique accross all tables in the extent of clazz.
        */
  -    public int getUniqueId(FieldDescriptor field) throws SequenceManagerException
  +    public int getUniqueId(FieldDescriptor field) 
       {
           return getNextId(field);
       }
  @@ -110,7 +110,7 @@
        * the returned uid is unique accross all tables in the extent of clazz.
        *
        */
  -    protected String getUniqueString(FieldDescriptor field) throws SequenceManagerException
  +    protected String getUniqueString(FieldDescriptor field)
       {
           return Integer.toString(getUniqueId(field));
       }
  @@ -119,7 +119,7 @@
        * returns a unique long value for class clazz and field fieldName.
        * the returned number is unique accross all tables in the extent of clazz.
        */
  -    protected long getUniqueLong(FieldDescriptor field) throws SequenceManagerException
  +    protected long getUniqueLong(FieldDescriptor field)
       {
           return getUniqueId(field);
       }
  @@ -128,7 +128,7 @@
        * returns a unique Object for class clazz and field fieldName.
        * the returned Object is unique accross all tables in the extent of clazz.
        */
  -    protected Object getUniqueObject(FieldDescriptor field) throws SequenceManagerException
  +    protected Object getUniqueObject(FieldDescriptor field)
       {
           return null; //getUniqueString(clazz, fieldName);
       }
  
  
  
  1.10      +2 -2      db-ojb/src/java/org/apache/ojb/broker/ant/DBUtility.java
  
  Index: DBUtility.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/ant/DBUtility.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DBUtility.java	4 Apr 2004 23:53:33 -0000	1.9
  +++ DBUtility.java	22 May 2004 11:24:51 -0000	1.10
  @@ -48,7 +48,7 @@
   	 * @throws ClassNotFoundException	Throws ClassNotFoundException if the jdbc driver class
can not be found.
   	 */
   	public DBUtility(String url, String user, String pwd) 
  -	throws SQLException,ClassNotFoundException
  +	throws SQLException
   	{
   		m_url = url;
   		m_user = user;
  @@ -77,7 +77,7 @@
   		}
   	}
   
  -	private Connection connect(String url, String user, String pwd) throws SQLException,ClassNotFoundException
  +	private Connection connect(String url, String user, String pwd) throws SQLException
   	{
   		m_connection = DriverManager.getConnection(url, user, pwd);			
   		return m_connection;
  
  
  

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


Mime
View raw message