本文整理了Java中org.pentaho.di.core.database.Database.insertRow()
方法的一些代码示例,展示了Database.insertRow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.insertRow()
方法的具体详情如下:
包路径:org.pentaho.di.core.database.Database
类名称:Database
方法名:insertRow
[英]Insert a row into the database using a prepared statement that has all values set.
[中]使用已设置所有值的准备语句将行插入数据库。
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Insert a row into the database using a prepared statement that has all values set.
*
* @param ps The prepared statement
* @param batch True if you want to use batch inserts (size = commit size)
* @return true if the rows are safe: if batch of rows was sent to the database OR if a commit was done.
* @throws KettleDatabaseException
*/
public boolean insertRow( PreparedStatement ps, boolean batch ) throws KettleDatabaseException {
return insertRow( ps, batch, true );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void insertRow( String tableName, RowMetaInterface fields, Object[] data ) throws KettleDatabaseException {
insertRow( null, tableName, fields, data );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void insertRow() throws KettleDatabaseException {
insertRow( prepStatementInsert );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void insertRow( boolean batch ) throws KettleDatabaseException {
insertRow( prepStatementInsert, batch );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void updateRow() throws KettleDatabaseException {
insertRow( prepStatementUpdate );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void insertRow( PreparedStatement ps ) throws KettleDatabaseException {
insertRow( ps, false );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void insertRow( String schemaName, String tableName, RowMetaInterface fields, Object[] data )
throws KettleDatabaseException {
prepareInsert( fields, schemaName, tableName );
setValuesInsert( fields, data );
insertRow();
closeInsert();
}
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized void insertTableRow( String tablename, RowMetaAndData values ) throws KettleException {
database.prepareInsert( values.getRowMeta(), tablename );
database.setValuesInsert( values );
database.insertRow();
database.closeInsert();
}
代码示例来源:origin: pentaho/pentaho-kettle
private void insertDatabaseAttributes( ObjectId idDatabase, Properties properties ) throws KettleException {
if ( properties.isEmpty() ) {
return;
}
Database db = repository.connectionDelegate.getDatabase();
boolean firstAttribute = true;
Enumeration<Object> keys = properties.keys();
while ( keys.hasMoreElements() ) {
String code = (String) keys.nextElement();
String attribute = (String) properties.get( code );
RowMetaAndData attributeData = createAttributeRow( idDatabase, code, attribute );
if ( firstAttribute ) {
db.prepareInsert( attributeData.getRowMeta(), KettleDatabaseRepository.TABLE_R_DATABASE_ATTRIBUTE );
firstAttribute = false;
}
db.setValuesInsert( attributeData );
db.insertRow( db.getPrepStatementInsert(), true, false );
}
db.executeAndClearBatch( db.getPrepStatementInsert() );
db.closeInsert();
}
}
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized ObjectId insertJobEntryCopy( ObjectId id_job, ObjectId id_jobentry,
ObjectId id_jobentry_type, int nr, long gui_location_x, long gui_location_y, boolean gui_draw,
boolean parallel ) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextJobEntryCopyID();
RowMetaAndData table = new RowMetaAndData();
//CHECKSTYLE:LineLength:OFF
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_COPY ), id );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY ), id_jobentry );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOB ), id_job );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE ), id_jobentry_type );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR ), new Long( nr ) );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X ), new Long( gui_location_x ) );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y ), new Long( gui_location_y ) );
table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW ), Boolean.valueOf( gui_draw ) );
table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL ), Boolean.valueOf( parallel ) );
repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOBENTRY_COPY );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
private synchronized void deleteValues( RowMetaInterface rowMeta, Object[] row ) throws KettleException {
// OK, now do the lookup.
// We need the lookupvalues for that.
Object[] deleteRow = new Object[data.deleteParameterRowMeta.size()];
int deleteIndex = 0;
for ( int i = 0; i < meta.getKeyStream().length; i++ ) {
if ( data.keynrs[i] >= 0 ) {
deleteRow[deleteIndex] = row[data.keynrs[i]];
deleteIndex++;
}
if ( data.keynrs2[i] >= 0 ) {
deleteRow[deleteIndex] = row[data.keynrs2[i]];
deleteIndex++;
}
}
data.db.setValues( data.deleteParameterRowMeta, deleteRow, data.prepStatementDelete );
if ( log.isDebug() ) {
logDebug( BaseMessages.getString( PKG, "Delete.Log.SetValuesForDelete", data.deleteParameterRowMeta
.getString( deleteRow ), rowMeta.getString( row ) ) );
}
data.db.insertRow( data.prepStatementDelete );
incrementLinesUpdated();
}
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized ObjectId insertJobEntryAttribute( ObjectId id_job, ObjectId id_jobentry, long nr,
String code, double value_num, String value_str )
throws KettleException {
ObjectId id = getNextJobEntryAttributeID();
RowMetaAndData table = new RowMetaAndData();
//CHECKSTYLE:LineLength:OFF
table
.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY_ATTRIBUTE ), id );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOB ), id_job );
table
.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY ), id_jobentry );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_NR ), new Long( nr ) );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE ), code );
table.addValue( new ValueMetaNumber( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_NUM ),
new Double( value_num ) );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_STR ), value_str );
database.prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOBENTRY_ATTRIBUTE );
database.setValuesInsert( table );
database.insertRow();
database.closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized ObjectId insertStep( ObjectId id_transformation, String name, String description,
String steptype, boolean distribute, long copies, long gui_location_x, long gui_location_y,
boolean gui_draw, String copiesString ) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextStepID();
ObjectId id_step_type = getStepTypeID( steptype );
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_ID_STEP ), id );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_ID_TRANSFORMATION ), id_transformation );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_STEP_NAME ), name );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_STEP_DESCRIPTION ), description );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_ID_STEP_TYPE ), id_step_type );
table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_STEP_DISTRIBUTE ), Boolean.valueOf( distribute ) );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_COPIES ), new Long( copies ) );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_X ), new Long( gui_location_x ) );
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_STEP_GUI_LOCATION_Y ), new Long( gui_location_y ) );
table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_STEP_GUI_DRAW ), Boolean.valueOf( gui_draw ) );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_STEP_COPIES_STRING ), copiesString );
repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_STEP );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
private synchronized ObjectId insertTransHop( ObjectId id_transformation, ObjectId id_step_from,
ObjectId id_step_to, boolean enabled ) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextTransHopID();
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_TRANS_HOP_ID_TRANS_HOP ), id );
table
.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_TRANS_HOP_ID_TRANSFORMATION ),
id_transformation );
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_TRANS_HOP_ID_STEP_FROM ), id_step_from );
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_TRANS_HOP_ID_STEP_TO ), id_step_to );
table.addValue( new ValueMetaBoolean(
KettleDatabaseRepository.FIELD_TRANS_HOP_ENABLED ), Boolean
.valueOf( enabled ) );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_TRANS_HOP );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized ObjectId insertPartition( ObjectId id_partition_schema, String partition_id ) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextPartitionID();
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION ), id );
table.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_PARTITION_ID_PARTITION_SCHEMA ),
id_partition_schema );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_PARTITION_PARTITION_ID ), partition_id );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_PARTITION );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
private synchronized ObjectId insertDirectory( ObjectId id_directory_parent, RepositoryDirectoryInterface dir ) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextDirectoryID();
String tablename = KettleDatabaseRepository.TABLE_R_DIRECTORY;
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY ), id );
table.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_DIRECTORY_ID_DIRECTORY_PARENT ),
id_directory_parent );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_DIRECTORY_DIRECTORY_NAME ), dir.getName() );
repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), tablename );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
public ObjectId insertNamespace( String namespace ) throws KettleException {
ObjectId idNamespace =
repository.connectionDelegate.getNextID(
quoteTable( KettleDatabaseRepository.TABLE_R_NAMESPACE ),
quote( KettleDatabaseRepository.FIELD_NAMESPACE_ID_NAMESPACE ) );
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_NAMESPACE_ID_NAMESPACE ), idNamespace );
table.addValue(
new ValueMetaString( KettleDatabaseRepository.FIELD_NAMESPACE_NAME ), namespace );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_NAMESPACE );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
if ( log.isDebug() ) {
log.logDebug( "Saved namespace [" + namespace + "]" );
}
return idNamespace;
}
代码示例来源:origin: pentaho/pentaho-kettle
private synchronized ObjectId insertDependency( ObjectId id_transformation, ObjectId id_database,
String tablename, String fieldname ) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextDepencencyID();
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DEPENDENCY ), id );
table.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_DEPENDENCY_ID_TRANSFORMATION ),
id_transformation );
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_DEPENDENCY_ID_DATABASE ), id_database );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_DEPENDENCY_TABLE_NAME ), tablename );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_DEPENDENCY_FIELD_NAME ), fieldname );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_DEPENDENCY );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized ObjectId insertPartitionSchema( PartitionSchema partitionSchema ) throws KettleException {
if ( getPartitionSchemaID( partitionSchema.getName() ) != null ) {
// This partition schema name is already in use. Throw an exception.
throw new KettleObjectExistsException( "Failed to create object in repository. Object ["
+ partitionSchema.getName() + "] already exists." );
}
ObjectId id = repository.connectionDelegate.getNextPartitionSchemaID();
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_ID_PARTITION_SCHEMA ), id );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_NAME ),
partitionSchema.getName() );
table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_DYNAMIC_DEFINITION ),
partitionSchema.isDynamicallyDefined() );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_PARTITIONS_PER_SLAVE ),
partitionSchema.getNumberOfPartitionsPerSlave() );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_PARTITION_SCHEMA );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
return id;
}
代码示例来源:origin: pentaho/pentaho-kettle
public ObjectId insertElementType( KDBRMetaStoreElementType type ) throws KettleException {
ObjectId idType =
repository.connectionDelegate.getNextID(
quoteTable( KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE ),
quote( KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE ) );
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE ), idType );
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_NAMESPACE ), type
.getNamespaceId() );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_ELEMENT_TYPE_NAME ), type.getName() );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_ELEMENT_TYPE_DESCRIPTION ), type
.getDescription() );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT_TYPE );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
type.setId( new LongObjectId( idType ) );
if ( log.isDebug() ) {
log.logDebug( "Saved element type [" + type.getName() + "]" );
}
return idType;
}
内容来源于网络,如有侵权,请联系作者删除!