commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject cvs commit: jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils DbUtils.java
Date Tue, 14 Jan 2003 18:20:55 GMT
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:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message