Java Code Examples for java.sql.Connection.setSavepoint()

The following are Jave code examples for showing how to use setSavepoint() of the java.sql.Connection class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-repository   File: ControlDAOImpl.java   View Source Code Vote up 5 votes
/**
 * Calls through to the {@link Connection#setSavepoint(String) current connection}.
 */
@Override
public Savepoint createSavepoint(final String savepoint)
{
    try
    {
        Connection connection = template.getConnection();
        return connection.setSavepoint(savepoint);
    }
    catch (SQLException e)
    {
        throw new RuntimeException("Failed to create SAVEPOINT: " + savepoint, e);
    }
}
 
Example 2
Project: UtilsMaven   File: JDBCUtils.java   View Source Code Vote up 5 votes
/**
 * 用于在事务中设置一个保存点,属于线程安全的
 */
public static void setSavePoint() {
    Connection connection = tl_conn.get();
    if (connection == null) {
        throw new RuntimeException("You do not start a Transaction so you can not set a savepoint!");
    }
    try {
        Stack<Savepoint> stack_sp = tl_sp.get();
        Savepoint sp = connection.setSavepoint();
        stack_sp.push(sp);
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}