本文整理汇总了Java中org.pentaho.di.core.database.Database类的典型用法代码示例。如果您正苦于以下问题:Java Database类的具体用法?Java Database怎么用?Java Database使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Database类属于org.pentaho.di.core.database包,在下文中一共展示了Database类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getTableFields
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public RowMetaInterface getTableFields()
{
RowMetaInterface fields = null;
if (databaseMeta != null)
{
Database db = new Database(loggingObject, databaseMeta);
try
{
db.connect();
fields = db.getTableFields(databaseMeta.getQuotedSchemaTableCombination(schemaName, tableName));
}
catch (KettleDatabaseException dbe)
{
logError(BaseMessages.getString(PKG, "DimensionLookupMeta.Log.DatabaseErrorOccurred") + dbe.getMessage()); //$NON-NLS-1$
}
finally
{
db.disconnect();
}
}
return fields;
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:23,代码来源:DimensionLookupMeta.java
示例2: init
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
/**
* This method is called by PDI during transformation startup.
*
* It should initialize required for step execution.
*
* The meta and data implementations passed in can safely be cast
* to the step's respective implementations.
*
* It is mandatory that super.init() is called to ensure correct behavior.
*
* Typical tasks executed here are establishing the connection to a database,
* as wall as obtaining resources, like file handles.
*
* @param smi step meta interface implementation, containing the step settings
* @param sdi step data interface implementation, used to store runtime information
*
* @return true if initialization completed successfully, false if there was an error preventing the step from working.
*
*/
public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
boolean result = true;
// Casting to step-specific implementation classes is safe
JdbcMetaDataMeta meta = (JdbcMetaDataMeta) smi;
JdbcMetaDataData data = (JdbcMetaDataData) sdi;
if (!super.init(meta, data)) return false;
try {
data.databases = new HashMap<String, Database>();
data.connections = new HashMap<String[], Connection>();
data.connectionKey = new String[4];
initMethod(meta, data);
initConnection(meta, data);
initOutputFields(meta, data);
}
catch(Exception exception) {
logError("Unexpected " + exception.getClass().getName() +" initializing step: " + exception.getMessage());
exception.printStackTrace();
result = false;
}
return result;
}
开发者ID:rpbouman,项目名称:pentaho-pdi-plugin-jdbc-metadata,代码行数:42,代码来源:JdbcMetaData.java
示例3: Repository
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public Repository(LogWriter log, RepositoryMeta repinfo, UserInfo userinfo)
{
this.repinfo = repinfo;
this.log = log;
this.userinfo = userinfo;
useBatchProcessing = true; // defaults to true;
database = new Database(repinfo.getConnection());
databaseMeta = database.getDatabaseMeta();
psStepAttributesLookup = null;
psStepAttributesInsert = null;
psTransAttributesLookup = null;
pstmt_entry_attributes = null;
this.majorVersion = REQUIRED_MAJOR_VERSION;
this.minorVersion = REQUIRED_MINOR_VERSION;
directoryTree = null;
creationHelper = new RepositoryCreationHelper(this);
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:Repository.java
示例4: getTableFields
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public RowMetaInterface getTableFields()
{
LogWriter log = LogWriter.getInstance();
RowMetaInterface fields = null;
if (databaseMeta!=null)
{
Database db = new Database(databaseMeta);
databases = new Database[] { db }; // Keep track of this one for cancelQuery
try
{
db.connect();
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(schemaName, tablename);
fields = db.getTableFields(schemaTable);
}
catch(KettleDatabaseException dbe)
{
log.logError(toString(), Messages.getString("DatabaseLookupMeta.ERROR0004.ErrorGettingTableFields")+dbe.getMessage()); //$NON-NLS-1$
}
finally
{
db.disconnect();
}
}
return fields;
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:27,代码来源:DatabaseLookupMeta.java
示例5: getDDL
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public void getDDL(String tableName)
{
Database db = new Database(dbMeta);
try
{
db.connect();
RowMetaInterface r = db.getTableFields(tableName);
String sql = db.getCreateTableStatement(tableName, r, null, false, null, true);
SQLEditor se = new SQLEditor(dbMeta, shell, SWT.NONE, dbMeta, dbcache, sql);
se.open();
}
catch(KettleDatabaseException dbe)
{
new ErrorDialog(shell, BaseMessages.getString(PKG,"Dialog.Error.Header"),
BaseMessages.getString(PKG,"DatabaseExplorerDialog.Error.RetrieveLayout"), dbe);
}
finally
{
db.disconnect();
}
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:DatabaseExplorerDialogLegacy.java
示例6: getInputData
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public boolean getInputData()
{
// Get some data...
CopyTableWizardPage1 page1 = (CopyTableWizardPage1)getPreviousPage();
Database sourceDb = new Database(page1.getSourceDatabase());
try
{
sourceDb.connect();
input = sourceDb.getTablenames();
}
catch(KettleDatabaseException dbe)
{
new ErrorDialog(shell, Messages.getString("CopyTableWizardPage2.ErrorGettingTables.DialogTitle"), Messages.getString("CopyTableWizardPage2.ErrorGettingTables.DialogMessage"), dbe); //$NON-NLS-1$ //$NON-NLS-2$
input = null;
return false;
}
finally
{
sourceDb.disconnect();
}
return true;
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:CopyTableWizardPage2.java
示例7: getInputData
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public boolean getInputData()
{
// Get some data...
RipDatabaseWizardPage1 page1 = (RipDatabaseWizardPage1)getPreviousPage();
Database sourceDb = new Database(page1.getSourceDatabase());
try
{
sourceDb.connect();
input = sourceDb.getTablenames(false); // Don't include the schema since it can cause invalid syntax
}
catch(KettleDatabaseException dbe)
{
new ErrorDialog(shell, "Error getting tables", "Error obtaining table list from database!", dbe);
input = null;
return false;
}
finally
{
sourceDb.disconnect();
}
return true;
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:24,代码来源:RipDatabaseWizardPage2.java
示例8: getDDL
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public void getDDL(String tableName)
{
Database db = new Database(dbMeta);
try
{
db.connect();
RowMetaInterface r = db.getTableFields(tableName);
String sql = db.getCreateTableStatement(tableName, r, null, false, null, true);
SQLEditor se = new SQLEditor(shell, SWT.NONE, dbMeta, dbcache, sql);
se.open();
}
catch(KettleDatabaseException dbe)
{
new ErrorDialog(shell, Messages.getString("Dialog.Error.Header"),
Messages.getString("DatabaseExplorerDialog.Error.RetrieveLayout"), dbe);
}
finally
{
db.disconnect();
}
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:22,代码来源:DatabaseExplorerDialog.java
示例9: execute
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
/**
* Execute fastload.
*
* @throws KettleException
* ...
*/
public void execute() throws KettleException {
if (this.meta.getTruncateTable().getValue()) {
Database db = new Database(this, this.meta.getDbMeta());
db.connect();
db.truncateTable(this.meta.getTargetTable().getValue());
db.commit();
db.disconnect();
}
startFastLoad();
if (this.meta.getUseControlFile().getValue()) {
this.invokeLoadingControlFile();
} else {
this.invokeLoadingCommand();
}
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:23,代码来源:TeraFast.java
示例10: getInputData
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public boolean getInputData()
{
// Get some data...
RipDatabaseWizardPage1 page1 = (RipDatabaseWizardPage1)getPreviousPage();
Database sourceDb = new Database(RipDatabaseWizard.loggingObject, page1.getSourceDatabase());
try
{
sourceDb.connect();
input = sourceDb.getTablenames(false); // Don't include the schema since it can cause invalid syntax
}
catch(KettleDatabaseException dbe)
{
new ErrorDialog(shell, "Error getting tables", "Error obtaining table list from database!", dbe);
input = null;
return false;
}
finally
{
sourceDb.disconnect();
}
return true;
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:24,代码来源:RipDatabaseWizardPage2.java
示例11: getSchemaNames
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
/**
* Presents a dialog box to select a schema from the database. Then sets the selected schema in the dialog
*/
private void getSchemaNames() {
DatabaseMeta databaseMeta = transMeta.findDatabase( wConnection.getText() );
if ( databaseMeta != null ) {
Database database = new Database( loggingObject, databaseMeta );
try {
database.connect();
String[] schemas = database.getSchemas();
if ( null != schemas && schemas.length > 0 ) {
schemas = Const.sortStrings( schemas );
EnterSelectionDialog dialog =
new EnterSelectionDialog( shell, schemas, BaseMessages.getString(
PKG, "SnowflakeBulkLoader.Dialog.AvailableSchemas.Title", wConnection.getText() ), BaseMessages
.getString( PKG, "SnowflakeBulkLoader.Dialog.AvailableSchemas.Message", wConnection.getText() ) );
String d = dialog.open();
if ( d != null ) {
wSchema.setText( Const.NVL( d, "" ) );
setTableFieldCombo();
}
} else {
MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR );
mb.setMessage( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.NoSchema.Error" ) );
mb.setText( BaseMessages.getString( PKG, "SnowflakeBulkLoader.Dialog.GetSchemas.Error" ) );
mb.open();
}
} catch ( Exception e ) {
new ErrorDialog( shell, BaseMessages.getString( PKG, "System.Dialog.Error.Title" ), BaseMessages
.getString( PKG, "SnowflakeBulkLoader.Dialog.ErrorGettingSchemas" ), e );
} finally {
database.disconnect();
}
}
}
开发者ID:inquidia,项目名称:PentahoSnowflakePlugin,代码行数:38,代码来源:SnowflakeBulkLoaderDialog.java
示例12: init
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
/**
* Initialize the step by connecting to the database and calculating some constants that will be used.
* @param smi The step meta
* @param sdi The step data
* @return True if successfully initialized
*/
public boolean init( StepMetaInterface smi, StepDataInterface sdi ) {
meta = (SnowflakeBulkLoaderMeta) smi;
data = (SnowflakeBulkLoaderData) sdi;
if ( super.init( smi, sdi ) ) {
data.splitnr = 0;
try {
data.databaseMeta = meta.getDatabaseMeta();
/* if ( !data.databaseMeta.getPluginId().equals( "SNOWFLAKE" ) ) {
throw new KettleException( "Database is not a Snowflake database" );
}
*/
data.db = new Database( this, data.databaseMeta );
data.db.shareVariablesWith( this );
data.db.connect();
if ( log.isBasic() ) {
logBasic( "Connected to database [" + meta.getDatabaseMeta() + "]" );
}
data.db.setCommit( Integer.MAX_VALUE );
initBinaryDataFields();
} catch ( Exception e ) {
logError( "Couldn't initialize binary data fields", e );
setErrors( 1L );
stopAll();
}
return true;
}
return false;
}
开发者ID:inquidia,项目名称:PentahoSnowflakePlugin,代码行数:42,代码来源:SnowflakeBulkLoader.java
示例13: getRequiredFields
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
/**
* Gets a list of fields in the database table
* @param space The variable space
* @return The metadata about the fields in the table.
* @throws KettleException
*/
public RowMetaInterface getRequiredFields( VariableSpace space ) throws KettleException {
String realTableName = space.environmentSubstitute( targetTable );
String realSchemaName = space.environmentSubstitute( targetSchema );
if ( databaseMeta != null ) {
Database db = new Database( loggingObject, databaseMeta );
try {
db.connect();
if ( !Const.isEmpty( realTableName ) ) {
String schemaTable = databaseMeta.getQuotedSchemaTableCombination( realSchemaName, realTableName );
// Check if this table exists...
if ( db.checkTableExists( schemaTable ) ) {
return db.getTableFields( schemaTable );
} else {
throw new KettleException( BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.TableNotFound" ) );
}
} else {
throw new KettleException( BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.TableNotSpecified" ) );
}
} catch ( Exception e ) {
throw new KettleException(
BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.ErrorGettingFields" ), e );
} finally {
db.disconnect();
}
} else {
throw new KettleException( BaseMessages.getString( PKG, "SnowflakeBulkLoaderMeta.Exception.ConnectionNotDefined" ) );
}
}
开发者ID:inquidia,项目名称:PentahoSnowflakePlugin,代码行数:39,代码来源:SnowflakeBulkLoaderMeta.java
示例14: getConnection
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public Connection getConnection() throws SQLException {
Database database = new Database( databaseMeta );
try {
database.connect();
} catch ( KettleException e ) {
e.printStackTrace();
throw new SQLException( e.getMessage() );
}
return database.getConnection();
}
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:11,代码来源:XmiToDatabaseMetaDatasourceService.java
示例15: clearLogTable
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
/**
* User requested to clear the log table.<br>
* Better ask confirmation
*/
private void clearLogTable(int index) {
LogTableInterface logTable = models[index].logTable;
if (logTable.isDefined()) {
String schemaTable = logTable.getQuotedSchemaTableCombination();
DatabaseMeta databaseMeta = logTable.getDatabaseMeta();
MessageBox mb = new MessageBox(transGraph.getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
mb.setMessage(BaseMessages.getString(PKG, "TransGraph.Dialog.AreYouSureYouWantToRemoveAllLogEntries.Message", schemaTable)); // Nothing found that matches your criteria //$NON-NLS-1$
mb.setText(BaseMessages.getString(PKG, "TransGraph.Dialog.AreYouSureYouWantToRemoveAllLogEntries.Title")); // Sorry! //$NON-NLS-1$
if (mb.open() == SWT.YES) {
Database database = new Database(loggingObject, databaseMeta);
try {
database.connect();
database.truncateTable(schemaTable);
} catch (Exception e) {
new ErrorDialog(transGraph.getShell(), BaseMessages.getString(PKG, "TransGraph.Dialog.ErrorClearningLoggingTable.Title"), //$NON-NLS-1$
BaseMessages.getString(PKG, "TransGraph.Dialog.ErrorClearningLoggingTable.Message"), e); //$NON-NLS-1$
} finally {
if (database != null) {
database.disconnect();
}
refreshHistory();
if (wText.get(index) != null) {
wText.get(index).setText(""); //$NON-NLS-1$
}
}
}
}
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:37,代码来源:TransHistoryDelegate.java
示例16: TruncateTables
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
private boolean TruncateTables(LogWriter log,String tablename, String schemaname, Database db)
{
boolean retval=false;
String realSchemaname=schemaname;
String realTablename=tablename;
try{
if(!Const.isEmpty(realSchemaname))
realTablename = db.getDatabaseMeta().getQuotedSchemaTableCombination(realSchemaname, realTablename);
// check if table exists!
if(db.checkTableExists(realTablename)){
if(!Const.isEmpty(realSchemaname))
db.truncateTable(realSchemaname, tablename);
else
db.truncateTable(tablename);
if(log.isDetailed()) log.logDetailed(toString(), Messages.getString("JobEntryTruncateTables.Log.TableTruncated",realTablename));
retval=true;
}else{
log.logError(toString(), Messages.getString("JobEntryTruncateTables.Error.CanNotFindTable",realTablename));
}
}catch (Exception e)
{
log.logError(toString(), Messages.getString("JobEntryTruncateTables.Error.CanNotTruncateTables",realTablename,e.toString()));
}
return retval;
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:30,代码来源:JobEntryTruncateTables.java
示例17: init
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public boolean init(StepMetaInterface smi, StepDataInterface sdi)
{
meta=(ExecSQLRowMeta)smi;
data=(ExecSQLRowData)sdi;
if (super.init(smi, sdi))
{
data.db = new Database(meta.getDatabaseMeta());
data.db.shareVariablesWith(this);
// Connect to the database
try
{
if (getTransMeta().isUsingUniqueConnections())
{
synchronized (getTrans()) { data.db.connect(getTrans().getThreadName(), getPartitionID()); }
}
else
{
data.db.connect(getPartitionID());
}
if (log.isDetailed()) logDetailed(Messages.getString("ExecSQLRow.Log.ConnectedToDB")); //$NON-NLS-1$
if(meta.getCommitSize()>1) data.db.setCommit(meta.getCommitSize());
return true;
}
catch(KettleException e)
{
logError(Messages.getString("ExecSQLRow.Log.ErrorOccurred")+e.getMessage()); //$NON-NLS-1$
setErrors(1);
stopAll();
}
}
return false;
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:38,代码来源:ExecSQLRow.java
示例18: getSQLStatements
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev)
{
SQLStatement retval = new SQLStatement(stepMeta.getName(), database, null); // default: nothing to do!
if (useDatabase) // Otherwise, don't bother!
{
if (database!=null)
{
Database db = new Database(loggingObject, database);
db.shareVariablesWith(transMeta);
try
{
db.connect();
if (!db.checkSequenceExists(schemaName, sequenceName))
{
String cr_table = db.getCreateSequenceStatement(sequenceName, startAt, incrementBy, maxValue, true);
retval.setSQL(cr_table);
}
else
{
retval.setSQL(null); // Empty string means: nothing to do: set it to null...
}
}
catch(KettleException e)
{
retval.setError(BaseMessages.getString(PKG, "AddSequenceMeta.ErrorMessage.UnableToConnectDB")+Const.CR+e.getMessage()); //$NON-NLS-1$
}
finally
{
db.disconnect();
}
}
else
{
retval.setError(BaseMessages.getString(PKG, "AddSequenceMeta.ErrorMessage.NoConnectionDefined")); //$NON-NLS-1$
}
}
return retval;
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:41,代码来源:AddSequenceMeta.java
示例19: init
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public boolean init(StepMetaInterface smi, StepDataInterface sdi)
{
meta=(InsertUpdateMeta)smi;
data=(InsertUpdateData)sdi;
if (super.init(smi, sdi))
{
try
{
data.db=new Database(meta.getDatabaseMeta());
data.db.shareVariablesWith(this);
if (getTransMeta().isUsingUniqueConnections())
{
synchronized (getTrans()) { data.db.connect(getTrans().getThreadName(), getPartitionID()); }
}
else
{
data.db.connect(getPartitionID());
}
data.db.setCommit(meta.getCommitSize());
return true;
}
catch(KettleException ke)
{
logError(Messages.getString("InsertUpdate.Log.ErrorOccurredDuringStepInitialize")+ke.getMessage()); //$NON-NLS-1$
}
}
return false;
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:31,代码来源:InsertUpdate.java
示例20: getTableFields
import org.pentaho.di.core.database.Database; //导入依赖的package包/类
public RowMetaInterface getTableFields()
{
LogWriter log = LogWriter.getInstance();
// Build a dummy parameter row...
//
RowMetaInterface param = new RowMeta();
for (int i=0;i<parameterField.length;i++)
{
param.addValueMeta( new ValueMeta(parameterField[i], parameterType[i]) );
}
RowMetaInterface fields = null;
if (databaseMeta!=null)
{
Database db = new Database(databaseMeta);
databases = new Database[] { db }; // Keep track of this one for cancelQuery
try
{
db.connect();
fields = db.getQueryFields(sql, true, param, new Object[param.size()]);
}
catch(KettleDatabaseException dbe)
{
log.logError(toString(), Messages.getString("DatabaseJoinMeta.Log.DatabaseErrorOccurred")+dbe.getMessage()); //$NON-NLS-1$
}
finally
{
db.disconnect();
}
}
return fields;
}
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:35,代码来源:DatabaseJoinMeta.java
注:本文中的org.pentaho.di.core.database.Database类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论