本文整理匯總了Java中org.openrdf.repository.RepositoryConnection.rollback方法的典型用法代碼示例。如果您正苦於以下問題:Java RepositoryConnection.rollback方法的具體用法?Java RepositoryConnection.rollback怎麽用?Java RepositoryConnection.rollback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.openrdf.repository.RepositoryConnection
的用法示例。
在下文中一共展示了RepositoryConnection.rollback方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
@Override
public DbInfo create( DbInfo t ) throws Exception {
RepositoryConnection rc = store.getConnection();
UriBuilder urib = UriBuilder.getBuilder( WEBDS.NAMESPACE + "dbinfo" );
URI uri = urib.uniqueUri();
rc.begin();
try{
rc.add( getCreateStatements( uri, t, rc.getValueFactory() ) );
rc.commit();
}
catch( RepositoryException re ){
rc.rollback();
throw re;
}
return t;
}
示例2: remove
import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
@Override
public void remove( DbInfo t ) throws Exception {
RepositoryConnection rc = store.getConnection();
Resource idToRemove = getId( t, rc );
if ( null != idToRemove ) {
try{
rc.begin();
rc.remove( idToRemove, null, null );
rc.commit();
}
catch( RepositoryException re ){
rc.rollback();
throw re;
}
}
}
示例3: update
import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
@Override
public void update( DbInfo data ) throws Exception {
RepositoryConnection rc = store.getConnection();
Resource id = getId( data, rc );
if ( null != id ) {
try{
rc.begin();
rc.remove( id, null, null );
rc.add( getCreateStatements( id, data, rc.getValueFactory() ) );
rc.commit();
}
catch( RepositoryException re ){
rc.rollback();
throw re;
}
}
}
示例4: update
import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
@Override
public void update( User user ) throws Exception {
RepositoryConnection rc = store.getConnection();
try {
Map<URI, DbAccess> accesses = getAccesses( user );
Resource id = getId( user, rc );
if ( null != id ) {
rc.begin();
rc.remove( id, null, null );
rc.add( getCreateStatements( id, user, rc.getValueFactory() ) );
addAccesses( id, accesses, rc );
rc.commit();
}
}
catch ( RepositoryException e ) {
log.error( e, e );
try {
rc.rollback();
}
catch ( Exception x ) {
log.warn( x, x );
}
}
}
示例5: setAccesses
import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
/**
* Sets the access level from the given map. To remove access from a DB, user
* {@link DbAccess#NONE}.
*
* @param user
* @param access a mapping of URIs (either {@link DbInfo#getDataUrl()} or
* {@link DbInfo#getInsightsUrl()}) and the access given
*/
public void setAccesses( User user, Map<URI, DbAccess> access ) {
RepositoryConnection rc = store.getConnection();
try {
rc.begin();
Resource id = getId( user, rc );
addAccesses( id, access, rc );
rc.commit();
}
catch ( RepositoryException e ) {
log.error( e, e );
try {
rc.rollback();
}
catch ( Exception x ) {
log.warn( x, x );
}
}
}
示例6: execute
import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
@Override
public void execute( ModificationExecutor exe ) throws RepositoryException {
RepositoryConnection rc = getRawConnection();
try {
if ( exe.execInTransaction() ) {
rc.begin();
}
exe.exec( rc );
if ( exe.execInTransaction() ) {
rc.commit();
}
}
catch ( RepositoryException e ) {
if ( exe.execInTransaction() ) {
rc.rollback();
}
throw e;
}
}
示例7: rollback
import org.openrdf.repository.RepositoryConnection; //導入方法依賴的package包/類
/**
* Rolls back a transaction, if there is a active transaction
* using a connection.
*
* This method is intended to roll back a transaction after an exception
* occured. Any occuring exceptions while rolling back will be added as
* suppressed exceptions to the given exception.
* @param conn the connection on which the transaction should be rolled back
* @param ex an exception that caused the rollback
*/
protected void rollback(RepositoryConnection conn, Exception ex) {
try {
if (conn.isActive()) {
conn.rollback();
}
} catch (RepositoryException ex2) {
ex.addSuppressed(ex2);
}
}