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

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

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

Database.execStatement介绍

[英]Execute an SQL statement on the database connection (has to be open)
[中]在数据库连接上执行SQL语句(必须打开)

代码示例

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

  1. /**
  2. * Execute an SQL statement on the database connection (has to be open)
  3. *
  4. * @param sql The SQL to execute
  5. * @return a Result object indicating the number of lines read, deleted, inserted, updated, ...
  6. * @throws KettleDatabaseException in case anything goes wrong.
  7. */
  8. public Result execStatement( String sql ) throws KettleDatabaseException {
  9. return execStatement( sql, null, null );
  10. }

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

  1. data.result = data.db.execStatement( data.sql );
  2. } else {
  3. data.result = data.db.execStatements( data.sql );

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

  1. @Override
  2. public void run() {
  3. try {
  4. data.db.execStatement( loadCommand );
  5. } catch ( Exception ex ) {
  6. this.ex = ex;
  7. }
  8. }

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

  1. public void execStatement( String sql ) throws KettleException {
  2. connectionDelegate.getDatabase().execStatement( sql );
  3. }

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

  1. public void truncateTable( String schema, String tablename ) throws KettleDatabaseException {
  2. if ( Utils.isEmpty( connectionGroup ) ) {
  3. String truncateStatement = databaseMeta.getTruncateTableStatement( schema, tablename );
  4. if ( truncateStatement == null ) {
  5. throw new KettleDatabaseException( "Truncate table not supported by "
  6. + databaseMeta.getDatabaseInterface().getPluginName() );
  7. }
  8. execStatement( truncateStatement );
  9. } else {
  10. execStatement( "DELETE FROM " + databaseMeta.getQuotedSchemaTableCombination( schema, tablename ) );
  11. }
  12. }

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

  1. public void truncateTable( String tablename ) throws KettleDatabaseException {
  2. if ( Utils.isEmpty( connectionGroup ) ) {
  3. String truncateStatement = databaseMeta.getTruncateTableStatement( null, tablename );
  4. if ( truncateStatement == null ) {
  5. throw new KettleDatabaseException( "Truncate table not supported by "
  6. + databaseMeta.getDatabaseInterface().getPluginName() );
  7. }
  8. execStatement( truncateStatement );
  9. } else {
  10. execStatement( "DELETE FROM " + databaseMeta.quoteField( tablename ) );
  11. }
  12. }

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

  1. public Long getNextBatchIdUsingLockTables( DatabaseMeta dbm, Database ldb, String schemaName, String tableName,
  2. String fieldName ) throws KettleDatabaseException {
  3. // The old way of doing things...
  4. Long rtn = null;
  5. // Make sure we lock that table to avoid concurrency issues
  6. String schemaAndTable = dbm.getQuotedSchemaTableCombination( schemaName, tableName );
  7. ldb.lockTables( new String[] { schemaAndTable, } );
  8. try {
  9. // Now insert value -1 to create a real write lock blocking the other
  10. // requests.. FCFS
  11. String sql = "INSERT INTO " + schemaAndTable + " (" + dbm.quoteField( fieldName ) + ") values (-1)";
  12. ldb.execStatement( sql );
  13. // Now this next lookup will stall on the other connections
  14. //
  15. rtn = ldb.getNextValue( null, schemaName, tableName, fieldName );
  16. } finally {
  17. // Remove the -1 record again...
  18. String sql = "DELETE FROM " + schemaAndTable + " WHERE " + dbm.quoteField( fieldName ) + "= -1";
  19. ldb.execStatement( sql );
  20. ldb.unlockTables( new String[] { schemaAndTable, } );
  21. }
  22. return rtn;
  23. }

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

  1. /**
  2. * Unlock certain tables in the database for write operations
  3. *
  4. * @param tableNames The tables to unlock
  5. * @throws KettleDatabaseException
  6. */
  7. public void unlockTables( String[] tableNames ) throws KettleDatabaseException {
  8. if ( Utils.isEmpty( tableNames ) ) {
  9. return;
  10. }
  11. // Quote table names too...
  12. //
  13. String[] quotedTableNames = new String[ tableNames.length ];
  14. for ( int i = 0; i < tableNames.length; i++ ) {
  15. quotedTableNames[ i ] = databaseMeta.getQuotedSchemaTableCombination( null, tableNames[ i ] );
  16. }
  17. // Get the SQL to unlock the (quoted) tables
  18. //
  19. String sql = databaseMeta.getSQLUnlockTables( quotedTableNames );
  20. if ( sql != null ) {
  21. execStatement( sql );
  22. }
  23. }

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

  1. @Override
  2. public boolean dropTable() {
  3. TableOutputMeta meta = getMeta();
  4. TableOutputData data = getData();
  5. String schema = meta.getSchemaName();
  6. String table = meta.getTableName();
  7. if ( schema != null && !schema.equals( "" ) ) {
  8. table = schema + "." + table;
  9. }
  10. String sql = "drop table " + table + ";";
  11. try {
  12. Result result = data.db.execStatement( sql );
  13. int status = result.getExitStatus();
  14. if ( status == 0 ) {
  15. util.updateMetadata( meta, -1 );
  16. }
  17. return status == 0;
  18. } catch ( KettleDatabaseException e ) {
  19. message = "Could not drop table: " + table;
  20. logError( message, e );
  21. }
  22. return false;
  23. }

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

  1. execStatement( sql, updateRowMeta, updateRowData );

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

  1. public synchronized void renameUser( ObjectId id_user, String newname ) throws KettleException {
  2. String sql =
  3. "UPDATE "
  4. + quoteTable( KettleDatabaseRepository.TABLE_R_USER ) + " SET "
  5. + quote( KettleDatabaseRepository.FIELD_USER_NAME ) + " = ? WHERE "
  6. + quote( KettleDatabaseRepository.FIELD_USER_ID_USER ) + " = ?";
  7. RowMetaAndData table = new RowMetaAndData();
  8. table.addValue(
  9. new ValueMetaString( KettleDatabaseRepository.FIELD_USER_NAME ), newname );
  10. table.addValue(
  11. new ValueMetaInteger( KettleDatabaseRepository.FIELD_USER_ID_USER ), id_user );
  12. repository.connectionDelegate.getDatabase().execStatement( sql, table.getRowMeta(), table.getData() );
  13. }
  14. }

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

  1. execStatement( sql, row.getRowMeta(), row.getData() );
  2. } catch ( Exception e ) {
  3. DatabaseLogExceptionFactory.getExceptionStrategy( logTable )

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

  1. public synchronized void moveJob( String jobname, ObjectId id_directory_from, ObjectId id_directory_to ) throws KettleException {
  2. String sql =
  3. "UPDATE "
  4. + quoteTable( KettleDatabaseRepository.TABLE_R_JOB ) + " SET "
  5. + quote( KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY ) + " = ? WHERE "
  6. + quote( KettleDatabaseRepository.FIELD_JOB_NAME ) + " = ? AND "
  7. + quote( KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY ) + " = ?";
  8. RowMetaAndData par = new RowMetaAndData();
  9. par.addValue(
  10. new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY ),
  11. id_directory_to );
  12. par.addValue(
  13. new ValueMetaString( KettleDatabaseRepository.FIELD_JOB_NAME ), jobname );
  14. par.addValue(
  15. new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY ),
  16. id_directory_from );
  17. repository.connectionDelegate.getDatabase().execStatement( sql, par.getRowMeta(), par.getData() );
  18. }

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

  1. param.addValue( valField, ValueMetaInterface.TYPE_INTEGER, Long.valueOf( maximum ) );
  2. db.execStatement( sql, param.getRowMeta(), param.getData() );

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

  1. .toString() ) );
  2. repository.connectionDelegate.getDatabase().execStatement( sql, r.getRowMeta(), r.getData() );

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

  1. public synchronized void moveTransformation( String transname, ObjectId id_directory_from,
  2. ObjectId id_directory_to ) throws KettleException {
  3. String nameField = quote( KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME );
  4. String sql =
  5. "UPDATE "
  6. + quoteTable( KettleDatabaseRepository.TABLE_R_TRANSFORMATION ) + " SET "
  7. + quote( KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY ) + " = ? WHERE " + nameField
  8. + " = ? AND " + quote( KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY ) + " = ?";
  9. RowMetaAndData par = new RowMetaAndData();
  10. par
  11. .addValue(
  12. new ValueMetaInteger(
  13. KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY ),
  14. id_directory_to );
  15. par.addValue( new ValueMetaString(
  16. KettleDatabaseRepository.FIELD_TRANSFORMATION_NAME ), transname );
  17. par
  18. .addValue(
  19. new ValueMetaInteger(
  20. KettleDatabaseRepository.FIELD_TRANSFORMATION_ID_DIRECTORY ),
  21. id_directory_from );
  22. repository.connectionDelegate.getDatabase().execStatement( sql, par.getRowMeta(), par.getData() );
  23. }

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

  1. try {
  2. db.connect();
  3. db.execStatement( "CALL VECTORWISE( COMBINE '" + data.schemaTable + " - " + data.schemaTable + "' )" );
  4. db.execStatement( "CALL VECTORWISE( COMBINE '" + data.schemaTable + " - " + data.schemaTable + "' )" );
  5. log.logDetailed( "Table " + data.schemaTable + " was truncated using a 'combine' statement." );
  6. } catch ( Exception e ) {

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

  1. public synchronized void renameJob( ObjectId id_job, RepositoryDirectoryInterface newParentDir, String newname ) throws KettleException {
  2. if ( newParentDir != null || newname != null ) {
  3. RowMetaAndData table = new RowMetaAndData();
  4. String sql = "UPDATE " + quoteTable( KettleDatabaseRepository.TABLE_R_JOB ) + " SET ";
  5. boolean additionalParameter = false;
  6. if ( newname != null ) {
  7. additionalParameter = true;
  8. sql += quote( KettleDatabaseRepository.FIELD_JOB_NAME ) + " = ? ";
  9. table.addValue(
  10. new ValueMetaString( KettleDatabaseRepository.FIELD_JOB_NAME ), newname );
  11. }
  12. if ( newParentDir != null ) {
  13. if ( additionalParameter ) {
  14. sql += ", ";
  15. }
  16. sql += quote( KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY ) + " = ? ";
  17. table.addValue( new ValueMetaInteger(
  18. KettleDatabaseRepository.FIELD_JOB_ID_DIRECTORY ), newParentDir
  19. .getObjectId() );
  20. }
  21. sql += "WHERE " + quote( KettleDatabaseRepository.FIELD_JOB_ID_JOB ) + " = ?";
  22. table.addValue(
  23. new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOB_ID_JOB ), id_job );
  24. log.logBasic( "sql = [" + sql + "]" );
  25. log.logBasic( "row = [" + table + "]" );
  26. repository.connectionDelegate.getDatabase().execStatement( sql, table.getRowMeta(), table.getData() );
  27. }
  28. }

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

  1. data.db.execStatement( databaseMeta.stripCR( isql ) );
  2. } catch ( KettleException e ) {
  3. throw new KettleDatabaseException( "Error inserting 'unknown' row in dimension ["

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

  1. log.logBasic( "row = [" + table + "]" );
  2. repository.connectionDelegate.getDatabase().execStatement( sql, table.getRowMeta(), table.getData() );
  3. repository.connectionDelegate.getDatabase().commit();

相关文章