本文整理了Java中org.pentaho.di.core.database.Database.prepareInsert()
方法的一些代码示例,展示了Database.prepareInsert()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.prepareInsert()
方法的具体详情如下:
包路径:org.pentaho.di.core.database.Database
类名称:Database
方法名:prepareInsert
[英]Prepare inserting values into a table, using the fields & values in a Row
[中]准备使用行中的字段和值将值插入表中
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Prepare inserting values into a table, using the fields & values in a Row
*
* @param rowMeta The row metadata to determine which values need to be inserted
* @param table The name of the table in which we want to insert rows
* @throws KettleDatabaseException if something went wrong.
*/
public void prepareInsert( RowMetaInterface rowMeta, String tableName ) throws KettleDatabaseException {
prepareInsert( rowMeta, null, tableName );
}
代码示例来源: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
table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_NOTE_DRAW_SHADOW ), Boolean.valueOf( drawshadow ) );
repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), KettleDatabaseRepository.TABLE_R_NOTE );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
代码示例来源: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
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
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
.valueOf( unconditional ) );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOB_HOP );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
代码示例来源: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
public synchronized ObjectId insertValue( String name, String type, String value_str, boolean isnull,
ObjectId id_value_prev ) throws KettleException {
ObjectId id_value = lookupValue( name, type, value_str, isnull );
// if it didn't exist yet: insert it!!
if ( id_value == null ) {
id_value = repository.connectionDelegate.getNextValueID();
// Let's see if the same value is not yet available?
String tablename = KettleDatabaseRepository.TABLE_R_VALUE;
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_VALUE_ID_VALUE ), id_value );
table.addValue(
new ValueMetaString( KettleDatabaseRepository.FIELD_VALUE_NAME ), name );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE ), type );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_VALUE_VALUE_STR ), value_str );
table.addValue(
new ValueMetaBoolean( KettleDatabaseRepository.FIELD_VALUE_IS_NULL ), Boolean
.valueOf( isnull ) );
repository.connectionDelegate.getDatabase().prepareInsert( table.getRowMeta(), tablename );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
}
return id_value;
}
代码示例来源: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
.getName() );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
代码示例来源: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 synchronized ObjectId insertJobEntry( ObjectId id_job, JobEntryBase jobEntryBase ) throws KettleException {
ObjectId id = repository.connectionDelegate.getNextJobEntryID();
ObjectId id_jobentry_type = getJobEntryTypeID( jobEntryBase.getPluginId() );
log.logDebug( "ID_JobEntry_type = " + id_jobentry_type + " for type = [" + jobEntryBase.getPluginId() + "]" );
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOBENTRY ), id );
table.addValue(
new ValueMetaInteger( KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOB ), id_job );
table
.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_JOBENTRY_ID_JOBENTRY_TYPE ),
id_jobentry_type );
table.addValue(
new ValueMetaString( KettleDatabaseRepository.FIELD_JOBENTRY_NAME ),
jobEntryBase.getName() );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_JOBENTRY_DESCRIPTION ), jobEntryBase
.getDescription() );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_JOBENTRY );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
jobEntryBase.setObjectId( id );
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;
}
代码示例来源:origin: pentaho/pentaho-kettle
private void insertAttributes( List<IMetaStoreAttribute> children, LongObjectId elementId,
LongObjectId parentAttributeId ) throws Exception {
for ( IMetaStoreAttribute child : children ) {
LongObjectId attributeId =
repository.connectionDelegate.getNextID(
quoteTable( KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE ),
quote( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ) );
RowMetaAndData table = new RowMetaAndData();
table.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ), attributeId.longValue() );
table.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT ),
elementId.longValue() );
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE_PARENT ), parentAttributeId.longValue() );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_KEY ), child.getId() );
table.addValue(
new ValueMetaString( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_VALUE ),
encodeAttributeValue( child.getValue() ) );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE );
repository.connectionDelegate.getDatabase().setValuesInsert( table );
repository.connectionDelegate.getDatabase().insertRow();
repository.connectionDelegate.getDatabase().closeInsert();
child.setId( attributeId.toString() );
}
}
内容来源于网络,如有侵权,请联系作者删除!