本文整理了Java中org.pentaho.di.core.database.Database.getOneRow()
方法的一些代码示例,展示了Database.getOneRow()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.getOneRow()
方法的具体详情如下:
包路径:org.pentaho.di.core.database.Database
类名称:Database
方法名:getOneRow
[英]Execute a query and return at most one row from the resultset
[中]执行查询并从结果集中最多返回一行
代码示例来源:origin: pentaho/pentaho-kettle
public RowMetaAndData getOneRow( String sql, RowMetaInterface rowMeta, Object[] rowData )
throws KettleDatabaseException {
return callRead( () -> database.getOneRow( sql, rowMeta, rowData ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
public RowMetaAndData getOneRow( String sql ) throws KettleDatabaseException {
return callRead( () -> database.getOneRow( sql ) );
}
代码示例来源:origin: pentaho/pentaho-kettle
public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException {
db = new Database( Spoon.loggingObject, dbMeta );
try {
db.connect();
String sql = dbMeta.getDatabaseInterface().getSelectCountStatement( tableName );
RowMetaAndData row = db.getOneRow( sql );
size = row.getRowMeta().getInteger( row.getData(), 0 );
if ( monitor.isCanceled() ) {
throw new InvocationTargetException( new Exception( "This operation was cancelled!" ) );
}
} catch ( KettleException e ) {
throw new InvocationTargetException( e, "Couldn't get a result because of an error :" + e.toString() );
} finally {
db.disconnect();
}
}
};
代码示例来源:origin: pentaho/pentaho-kettle
getOneRow( "SELECT MAX(" + databaseMeta.quoteField( val_key ) + ") FROM " + schemaTable );
if ( rmad != null ) {
long previous;
代码示例来源:origin: pentaho/pentaho-kettle
/**
* See if the column specified exists by reading
*
* @param columnname The name of the column to check.
* @param tablename The name of the table to check.<br> This is supposed to be the properly quoted name of the table
* or the complete schema-table name combination.
* @return true if the table exists, false if it doesn't.
* @deprecated Deprecated in favor of the smarter {@link #checkColumnExists(String, String, String)}
*/
public boolean checkColumnExists( String columnname, String tablename ) throws KettleDatabaseException {
try {
if ( log.isDebug() ) {
log.logDebug( "Checking if column [" + columnname + "] exists in table [" + tablename + "] !" );
}
// Just try to read from the table.
String sql = databaseMeta.getSQLColumnExists( columnname, tablename );
try {
getOneRow( sql );
return true;
} catch ( KettleDatabaseException e ) {
return false;
}
} catch ( Exception e ) {
throw new KettleDatabaseException( "Unable to check if column ["
+ columnname + "] exists in table [" + tablename + "] on connection [" + databaseMeta.getName() + "]", e );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
private synchronized LongObjectId getNextTableID( String tablename, String idfield ) throws KettleException {
LongObjectId retval = null;
RowMetaAndData r = callRead( () -> database.getOneRow( "SELECT MAX(" + idfield + ") FROM " + tablename ) );
if ( r != null ) {
Long id = r.getInteger( 0 );
if ( id == null ) {
if ( log.isDebug() ) {
log.logDebug( "no max(" + idfield + ") found in table " + tablename );
}
retval = new LongObjectId( 1 );
} else {
if ( log.isDebug() ) {
log.logDebug( "max(" + idfield + ") found in table " + tablename + " --> " + idfield + " number: " + id );
}
retval = new LongObjectId( id.longValue() + 1L );
}
}
return retval;
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* See if the table specified exists by reading
*
* @param tablename
* The name of the table to check.<br>
* This is supposed to be the properly quoted name of the table or the complete schema-table name
* combination.
* @return true if the table exists, false if it doesn't.
* @deprecated Deprecated in favor of {@link #checkTableExists(String, String)}
*/
public boolean checkTableExists( String tablename ) throws KettleDatabaseException {
try {
if ( log.isDebug() ) {
log.logDebug( "Checking if table [" + tablename + "] exists!" );
}
// Just try to read from the table.
String sql = databaseMeta.getSQLTableExists( tablename );
try {
getOneRow( sql );
return true;
} catch ( KettleDatabaseException e ) {
return false;
}
} catch ( Exception e ) {
throw new KettleDatabaseException( "Unable to check if table [" + tablename + "] exists on connection [" + databaseMeta.getName() + "]", e );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
RowMetaAndData row = db.getOneRow( countStatement );
if ( row != null ) {
rowsCount = row.getInteger( 0 );
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized int countNrJobAttributes( ObjectId id_job, String code ) throws KettleException {
String sql =
"SELECT COUNT(*) FROM "
+ databaseMeta.getQuotedSchemaTableCombination( null, KettleDatabaseRepository.TABLE_R_JOB_ATTRIBUTE )
+ " WHERE " + quote( KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB ) + " = ? AND "
+ quote( KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_CODE ) + " = ?";
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB ), id_job );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_CODE ), code );
RowMetaAndData r = callRead( () -> database.getOneRow( sql, table.getRowMeta(), table.getData() ) );
if ( r == null || r.getData() == null ) {
return 0;
}
return (int) r.getInteger( 0, 0L );
}
代码示例来源:origin: pentaho/pentaho-kettle
"SELECT count(*) FROM "
+ data.schemaTable + " WHERE " + databaseMeta.quoteField( meta.getKeyField() ) + " = " + start_tk;
RowMetaAndData r = data.db.getOneRow( sql );
Long count = r.getRowMeta().getInteger( r.getData(), 0 );
if ( count.longValue() != 0 ) {
"SELECT count(*) FROM "
+ data.schemaTable + " WHERE " + databaseMeta.quoteField( meta.getKeyField() ) + " = " + start_tk;
RowMetaAndData r = data.db.getOneRow( sql );
Long count = r.getRowMeta().getInteger( r.getData(), 0 );
if ( count.longValue() == 0 ) {
代码示例来源:origin: pentaho/pentaho-kettle
RowMetaAndData param = new RowMetaAndData();
param.addValue( seqField, ValueMetaInterface.TYPE_STRING, name );
RowMetaAndData row = db.getOneRow( sql, param.getRowMeta(), param.getData() );
long value;
if ( row != null && row.getData() != null ) {
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized int countNrTransAttributes( ObjectId id_transformation, String code ) throws KettleException {
String sql =
"SELECT COUNT(*) FROM "
+ databaseMeta
.getQuotedSchemaTableCombination( null, KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE )
+ " WHERE " + quote( KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION ) + " = ? AND "
+ quote( KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE ) + " = ?";
RowMetaAndData table = new RowMetaAndData();
table.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION ),
id_transformation );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE ), code );
RowMetaAndData r = callRead( () -> database.getOneRow( sql, table.getRowMeta(), table.getData() ) );
if ( r == null || r.getData() == null ) {
return 0;
}
return (int) r.getInteger( 0, 0L );
}
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized int countNrJobEntryAttributes( ObjectId id_jobentry, String code ) throws KettleException {
String sql =
"SELECT COUNT(*) FROM "
+ databaseMeta.getQuotedSchemaTableCombination(
null, KettleDatabaseRepository.TABLE_R_JOBENTRY_ATTRIBUTE ) + " WHERE "
+ quote( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY ) + " = ? AND "
+ quote( KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE ) + " = ?";
RowMetaAndData table = new RowMetaAndData();
table.addValue(
new ValueMetaInteger(
KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY ),
id_jobentry );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE ), code );
RowMetaAndData r = callRead( () -> database.getOneRow( sql, table.getRowMeta(), table.getData() ) );
if ( r == null || r.getData() == null ) {
return 0;
}
return (int) r.getInteger( 0, 0L );
}
代码示例来源:origin: pentaho/pentaho-kettle
sql += " ORDER BY " + dbMeta.quoteField( logTable.getLogDateField().getFieldName() ) + " DESC";
RowMetaAndData oneRow = database.getOneRow( sql );
String status = oneRow.getString( 0, "?" );
Date date = oneRow.getDate( 1, null );
代码示例来源:origin: pentaho/pentaho-kettle
public synchronized int countNrStepAttributes( ObjectId id_step, String code ) throws KettleException {
if ( stepAttributesBuffer != null ) {
// see if we can do this in memory...
int nr = searchNrStepAttributes( id_step, code );
return nr;
} else {
String sql =
"SELECT COUNT(*) FROM "
+ databaseMeta.getQuotedSchemaTableCombination(
null, KettleDatabaseRepository.TABLE_R_STEP_ATTRIBUTE ) + " WHERE "
+ quote( KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_STEP ) + " = ? AND "
+ quote( KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_CODE ) + " = ?";
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger(
KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_STEP ), id_step );
table.addValue( new ValueMetaString(
KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_CODE ), code );
RowMetaAndData r = callRead( () -> database.getOneRow( sql, table.getRowMeta(), table.getData() ) );
if ( r == null || r.getData() == null ) {
return 0;
}
return (int) r.getInteger( 0, 0L );
}
}
代码示例来源:origin: pentaho/pentaho-kettle
try {
lastUpgrade = callRead( () ->
database.getOneRow( "SELECT "
+ quote( KettleDatabaseRepository.FIELD_VERSION_MAJOR_VERSION ) + ", "
+ quote( KettleDatabaseRepository.FIELD_VERSION_MINOR_VERSION ) + ", "
callRead( () -> database.getOneRow( "SELECT * FROM " + userTable ) );
代码示例来源:origin: pentaho/pentaho-kettle
RowMetaAndData row = db.getOneRow( countSQLStatement );
if ( row != null ) {
rowsCount = row.getInteger( 0 );
代码示例来源:origin: pentaho/pentaho-kettle
RowMetaAndData r1 = maxdb.getOneRow( sql );
if ( r1 != null ) {
RowMetaAndData r1 = depdb.getOneRow( sql );
if ( r1 != null ) {
代码示例来源:origin: pentaho/pentaho-kettle
if ( upgrade ) {
lookup =
database.getOneRow( "SELECT "
+ repository.quote( KettleDatabaseRepository.FIELD_DATABASE_CONTYPE_ID_DATABASE_CONTYPE )
+ " FROM " + schemaTable + " WHERE "
if ( upgrade ) {
lookup =
database.getOneRow( "SELECT "
+ repository.quote( KettleDatabaseRepository.FIELD_LOGLEVEL_ID_LOGLEVEL ) + " FROM "
+ schemaTable + " WHERE " + database.getDatabaseMeta().quoteField( "CODE" ) + " = '" + code[i]
if ( upgrade ) {
lookup =
database.getOneRow( "SELECT "
+ repository.quote( KettleDatabaseRepository.FIELD_USER_ID_USER ) + " FROM " + schemaTable
+ " WHERE " + repository.quote( KettleDatabaseRepository.FIELD_USER_LOGIN ) + " = '" + user[i]
内容来源于网络,如有侵权,请联系作者删除!