org.pentaho.di.core.database.Database.unlockTables()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中org.pentaho.di.core.database.Database.unlockTables()方法的一些代码示例,展示了Database.unlockTables()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.unlockTables()方法的具体详情如下:
包路径:org.pentaho.di.core.database.Database
类名称:Database
方法名:unlockTables

Database.unlockTables介绍

[英]Unlock certain tables in the database for write operations
[中]为写操作解锁数据库中的某些表

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public synchronized void unlockRepository() throws KettleException {
 if ( database.getDatabaseMeta().needsToLockAllTables() ) {
  database.unlockTables( KettleDatabaseRepository.repositoryTableNames );
 } else {
  database.unlockTables( new String[] { KettleDatabaseRepository.TABLE_R_REPOSITORY_LOG, } );
 }
}

代码示例来源:origin: pentaho/pentaho-kettle

@Override
public Long getNextBatchIdUsingLockTables( DatabaseMeta dbm, Database ldb, String schemaName, String tableName,
 String fieldName ) throws KettleDatabaseException {
 Long rtn = null;
 // Make sure we lock that table to avoid concurrency issues
 ldb.lockTables( new String[] { dbm.getQuotedSchemaTableCombination( schemaName, tableName ), } );
 try {
  rtn = ldb.getNextValue( null, schemaName, tableName, fieldName );
 } finally {
  ldb.unlockTables( new String[] { tableName, } );
 }
 return rtn;
}

代码示例来源:origin: pentaho/pentaho-kettle

public Long getNextBatchIdUsingLockTables( DatabaseMeta dbm, Database ldb, String schemaName, String tableName,
 String fieldName ) throws KettleDatabaseException {
 // The old way of doing things...
 Long rtn = null;
 // Make sure we lock that table to avoid concurrency issues
 String schemaAndTable = dbm.getQuotedSchemaTableCombination( schemaName, tableName );
 ldb.lockTables( new String[] { schemaAndTable, } );
 try {
  // Now insert value -1 to create a real write lock blocking the other
  // requests.. FCFS
  String sql = "INSERT INTO " + schemaAndTable + " (" + dbm.quoteField( fieldName ) + ") values (-1)";
  ldb.execStatement( sql );
  // Now this next lookup will stall on the other connections
  //
  rtn = ldb.getNextValue( null, schemaName, tableName, fieldName );
 } finally {
  // Remove the -1 record again...
  String sql = "DELETE FROM " + schemaAndTable + " WHERE " + dbm.quoteField( fieldName ) + "= -1";
  ldb.execStatement( sql );
  ldb.unlockTables( new String[] { schemaAndTable, } );
 }
 return rtn;
}

相关文章

微信公众号

最新文章

更多