bayard      2003/01/14 10:20:55

  Modified:    dbutils/src/java/org/apache/commons/dbutils DbUtils.java
  Log:
  Added methods to commit, then close. Both noisy and quietly variants.
  
  Revision  Changes    Path
  1.6       +23 -0     
jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java
  
  Index: DbUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/DbUtils.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DbUtils.java      1 Dec 2002 13:12:54 -0000       1.5
  +++ DbUtils.java      14 Jan 2003 18:20:55 -0000      1.6
  @@ -297,6 +297,29 @@
           }
       }
   
  +    /**
  +     * Commits a connection then closes it, avoid closing if null.
  +     */
  +    public static void commitAndClose(Connection conn) throws SQLException {
  +        if (conn == null) {
  +            return;
  +        }
  +        conn.commit();
  +        conn.close();
  +    }
  +
  +    /**
  +     * Commits a connection then closes it, avoid closing if null and 
  +     * hide any exceptions that occur.
  +     */
  +    public static void commitAndCloseQuietly(Connection conn) {
  +        try {
  +            commitAndClose(conn);
  +        } catch (SQLException sqle) {
  +            // quiet
  +        }
  +    }
  +
       public static void printStackTrace(SQLException sqle, java.io.PrintStream ps){
           
           SQLException next = sqle;
  
  
  

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

Reply via email to