arminw      2005/10/27 10:33:23

  Modified:    src/java/org/apache/ojb/broker/accesslayer Tag:
                        OJB_1_0_RELEASE StatementsForClassImpl.java
  Log:
  use ExceptionHelper for SQLExceptions, code cleanup
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.22.2.7  +9 -20     
db-ojb/src/java/org/apache/ojb/broker/accesslayer/Attic/StatementsForClassImpl.java
  
  Index: StatementsForClassImpl.java
  ===================================================================
  RCS file: 
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/Attic/StatementsForClassImpl.java,v
  retrieving revision 1.22.2.6
  retrieving revision 1.22.2.7
  diff -u -r1.22.2.6 -r1.22.2.7
  --- StatementsForClassImpl.java       5 Oct 2005 18:01:25 -0000       1.22.2.6
  +++ StatementsForClassImpl.java       27 Oct 2005 17:33:23 -0000      1.22.2.7
  @@ -34,6 +34,7 @@
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.ojb.broker.util.ExceptionHelper;
   
   /**
    * This class serves as a cache for Statements that are
  @@ -79,20 +80,12 @@
   
           // detect JDBC level
           double level = jcd.getJdbcLevel();
  -        if (level == 1.0)
  -        {
  -            FORCEJDBC1_0 = true;
  -        }
  -        else
  -        {
  -            FORCEJDBC1_0 = false;
  -        }
  +        FORCEJDBC1_0 = level == 1.0;
       }
   
       /**
        * Answer true if a PreparedStatement has to be used
        * <br>false for a CallableStatement
  -     * @return
        */
       protected boolean usePreparedDeleteStatement()
       {
  @@ -124,7 +117,7 @@
       public Statement getGenericStmt(Connection con, boolean scrollable)
           throws PersistenceBrokerSQLException
       {
  -        Statement stmt = null;
  +        Statement stmt;
           try
           {
               stmt = createStatement(con, scrollable,
  @@ -132,8 +125,7 @@
           }
           catch (SQLException ex)
           {
  -            log.error(ex);
  -            throw new PersistenceBrokerSQLException(ex);
  +            throw ExceptionHelper.generateException("Can't prepare 
statement:", ex, null, log);
           }
           return stmt;
       }
  @@ -141,7 +133,6 @@
       /**
        * Answer true if a PreparedStatement has to be used
        * <br>false for a CallableStatement
  -     * @return
        */
       protected boolean usePreparedInsertStatement()
       {
  @@ -174,7 +165,7 @@
                                                boolean scrollable, int 
explicitFetchSizeHint, boolean callableStmt)
           throws PersistenceBrokerSQLException
       {
  -        PreparedStatement stmt = null;
  +        PreparedStatement stmt;
           try
           {
               stmt = prepareStatement(con, sql, scrollable,
  @@ -182,8 +173,7 @@
           }
           catch (SQLException ex)
           {
  -            log.error("Can't prepare statement: " + sql, ex);
  -            throw new PersistenceBrokerSQLException(ex);
  +            throw ExceptionHelper.generateException("Can't prepare 
statement:", ex, sql, log);
           }
           return stmt;
       }
  @@ -208,7 +198,6 @@
       /**
        * Answer true if a PreparedStatement has to be used
        * <br>false for a CallableStatement
  -     * @return
        */
       protected boolean usePreparedUpdateStatement()
       {
  @@ -259,7 +248,7 @@
                                                    int explicitFetchSizeHint)
           throws SQLException
       {
  -        PreparedStatement result = null;
  +        PreparedStatement result;
   
           // if a JDBC1.0 driver is used the signature
           // prepareStatement(String, int, int) is  not defined.
  @@ -363,7 +352,7 @@
       private Statement createStatement(Connection con, boolean scrollable, 
int explicitFetchSizeHint)
           throws java.sql.SQLException
       {
  -        Statement result = null;
  +        Statement result;
           try
           {
               // if necessary use JDBC1.0 methods
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to