List of usage examples for java.sql Connection commit
void commit() throws SQLException;
Connection
object. From source file:com.fileanalyzer.dao.impl.FileStatisticDAOImpl.java
@Override public void add(FileStatistic fStat) { Connection con = null; PreparedStatement preparedStatement = null; try {/*from www . j a v a2 s . c o m*/ con = DBConnector.getConnection(); con.setAutoCommit(false); preparedStatement = con.prepareStatement(getInsertByFileStatistic(fStat)); preparedStatement.executeUpdate(); con.commit(); } catch (SQLException e) { handleException(e, con); } finally { doFinal(con, preparedStatement); } }
From source file:com.agiletec.aps.system.services.authorization.AuthorizationDAO.java
protected void addUpdateUserAuthorizations(String username, List<Authorization> authorizations, boolean update) { Connection conn = null; try {// w ww. j a v a 2 s.c om conn = this.getConnection(); conn.setAutoCommit(false); if (update) { super.executeQueryWithoutResultset(conn, DELETE_USER_AUTHORIZATIONS, username); } this.addUserAuthorizations(username, authorizations, conn); conn.commit(); } catch (Throwable t) { this.executeRollback(conn); _logger.error("Error detected while addind user authorizations", t); throw new RuntimeException("Error detected while addind user authorizations", t); } finally { this.closeConnection(conn); } }
From source file:com.splicemachine.mrio.api.core.SMSQLUtil.java
public void commit(Connection conn) throws SQLException { conn.commit(); }
From source file:com.fileanalyzer.dao.impl.FilesDAOImpl.java
@Override public void add(Files fileInDb) { Connection con = null; PreparedStatement preparedStatement = null; try {//from www .j a va2 s . c om con = DBConnector.getConnection(); con.setAutoCommit(false); preparedStatement = con.prepareStatement(getInsertByFiles(fileInDb)); preparedStatement.executeUpdate(); con.commit(); } catch (SQLException e) { handleException(e, con); } finally { doFinal(con, preparedStatement); } }
From source file:com.krawler.esp.portalmsg.Mail.java
public static String DeleteFoldernameForMailuser(Connection conn, String folderid) throws ServiceException { String query = null;/*www. j a va 2 s.co m*/ // Object[] params = { null }; String query1 = "Update mailmessages set folder='2' where folder=?"; DbUtil.executeUpdate(conn, query1, folderid); conn.commit(); query = "Delete from mailmsgfoldermap where folder_id = ?"; // params[0] = folderid; int numRows = DbUtil.executeUpdate(conn, query, folderid); if (numRows == 0) { folderid = "-2"; } return folderid; }
From source file:com.fileanalyzer.dao.impl.FileStatisticDAOImpl.java
@Override public void update(FileStatistic fStat) { Connection con = null; PreparedStatement preparedStatement = null; try {/*from ww w. jav a 2 s.c o m*/ con = DBConnector.getConnection(); con.setAutoCommit(false); preparedStatement = con.prepareStatement(SqlGenerator.getUpdateByFileStatistic(fStat)); preparedStatement.executeUpdate(); con.commit(); } catch (SQLException e) { handleException(e, con); } finally { doFinal(con, preparedStatement); } }
From source file:com.fileanalyzer.dao.impl.FilesDAOImpl.java
@Override public void update(Files fileInDb) { Connection con = null; PreparedStatement preparedStatement = null; try {//from w w w . ja v a 2 s . c om con = DBConnector.getConnection(); con.setAutoCommit(false); preparedStatement = con.prepareStatement(SqlGenerator.getUpdateByFiles(fileInDb)); preparedStatement.executeUpdate(); con.commit(); } catch (SQLException e) { handleException(e, con); } finally { doFinal(con, preparedStatement); } }
From source file:localdomain.localhost.CasInitializer.java
@ManagedOperation public void createUser(@NotNull String username, @NotNull String clearTextPassword) { Connection cnn = null; try {//from www . j av a2 s.c o m cnn = dataSource.getConnection(); cnn.setAutoCommit(false); insertUser(username, clearTextPassword, cnn); cnn.commit(); } catch (RuntimeException e) { rollbackQuietly(cnn); String msg = "Exception creating '" + username + "': " + e; logger.warn(msg, e); throw new RuntimeException(msg); } catch (SQLException e) { rollbackQuietly(cnn); String msg = "Exception creating '" + username + "': " + e; logger.warn(msg, e); throw new RuntimeException(msg); } finally { closeQuietly(cnn); } }
From source file:hermes.store.schema.DefaultJDBCAdapter.java
public void createDatabase(Connection connection) throws SQLException { Hermes.ui.getDefaultMessageSink().add("Initialising message stores..."); executeStatements(connection, statements.getCreateDatabaseStatements(maxMessageSize, maxDestinationSize)); connection.commit(); Hermes.ui.getDefaultMessageSink().add("Initialising message stores... done."); }
From source file:com.fileanalyzer.dao.impl.FileStatisticDAOImpl.java
@Override public void delete(FileStatistic fStat) { Connection con = null; Statement statement = null;// w w w .j ava 2s. com try { con = DBConnector.getConnection(); con.setAutoCommit(false); statement = con.createStatement(); statement.execute("delete from " + FileStatistic.FileStatisticKey.TABLE + " where id=" + fStat.getId()); con.commit(); } catch (SQLException e) { if (con != null) { try { log.error("Transaction is being rolled back", e); con.rollback(); } catch (SQLException excep) { log.error(excep); } } } finally { if (statement != null) { try { statement.close(); } catch (SQLException ex) { log.error(ex); } } try { con.setAutoCommit(true); } catch (SQLException ex) { log.error("setAutoCommit(true)", ex); } if (con != null) { try { con.close(); } catch (SQLException ex) { log.error(ex); } } } }