| | |
| | | /** |
| | | * Get a database connection |
| | | * @return a database connection |
| | | * @throws SQLException |
| | | */ |
| | | public Connection getConnection() { |
| | | Connection c = null; |
| | |
| | | try { |
| | | c.setAutoCommit(false); |
| | | } catch(SQLException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | logger.log(Level.SEVERE, ex.getMessage(), ex); |
| | | } finally { |
| | | // .. |
| | | } |
| | |
| | | public void commit(Connection c) { |
| | | try { |
| | | c.commit(); |
| | | c.setAutoCommit(true); |
| | | } catch(SQLException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | logger.log(Level.SEVERE, ex.getMessage(), ex); |
| | | } finally { |
| | | // ... |
| | | try { |
| | | c.setAutoCommit(true); |
| | | } catch (SQLException ex) { |
| | | logger.log(Level.SEVERE, ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void rollback(Connection c) { |
| | | try { |
| | | c.rollback(); |
| | | c.setAutoCommit(true); |
| | | } catch(SQLException ex) { |
| | | logger.log(Level.SEVERE, ex.getLocalizedMessage(), ex); |
| | | } finally { |
| | | // ... |
| | | try { |
| | | c.setAutoCommit(true); |
| | | } catch (SQLException ex) { |
| | | logger.log(Level.SEVERE, ex.getMessage(), ex); |
| | | } |
| | | } |
| | | } |
| | | |