code: public static void commitAndClose(Connection conn) throws SQLException {
          if (conn != null) {
              try {
                  conn.commit();
              } finally {
                  conn.close();
              }
          }
      }
docs: Commits a <code>Connection</code> then closes it, avoid closing if null.
  
  @param conn Connection to close.
  @throws java.sql.SQLException if a database access error occurs