本文整理汇总了Java中org.pentaho.di.core.database.DatabaseMeta.setObjectId方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMeta.setObjectId方法的具体用法?Java DatabaseMeta.setObjectId怎么用?Java DatabaseMeta.setObjectId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.database.DatabaseMeta
的用法示例。
在下文中一共展示了DatabaseMeta.setObjectId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadDatabaseMeta
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
/**
*
* Load the Database Info
*/
public DatabaseMeta loadDatabaseMeta(ObjectId id_database) throws KettleException
{
DatabaseMeta databaseMeta = new DatabaseMeta();
try
{
RowMetaAndData r = getDatabase(id_database);
if (r!=null)
{
ObjectId id_database_type = new LongObjectId( r.getInteger( KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_TYPE, 0) ); // con_type
String dbTypeDesc = getDatabaseTypeCode( id_database_type );
if (dbTypeDesc!=null)
{
databaseMeta.setDatabaseInterface(DatabaseMeta.getDatabaseInterface(dbTypeDesc));
databaseMeta.setAttributes(new Properties()); // new attributes
}
else
{
// throw new KettleException("No database type was specified [id_database_type="+id_database_type+"]");
}
databaseMeta.setObjectId(id_database);
databaseMeta.setName( r.getString(KettleDatabaseRepository.FIELD_DATABASE_NAME, "") );
ObjectId id_database_contype = new LongObjectId( r.getInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_CONTYPE, 0) ); // con_access
databaseMeta.setAccessType( DatabaseMeta.getAccessType( getDatabaseConTypeCode( id_database_contype)) );
databaseMeta.setHostname( r.getString(KettleDatabaseRepository.FIELD_DATABASE_HOST_NAME, "") );
databaseMeta.setDBName( r.getString(KettleDatabaseRepository.FIELD_DATABASE_DATABASE_NAME, "") );
databaseMeta.setDBPort( r.getString(KettleDatabaseRepository.FIELD_DATABASE_PORT, "") );
databaseMeta.setUsername( r.getString(KettleDatabaseRepository.FIELD_DATABASE_USERNAME, "") );
databaseMeta.setPassword( Encr.decryptPasswordOptionallyEncrypted( r.getString(KettleDatabaseRepository.FIELD_DATABASE_PASSWORD, "") ) );
databaseMeta.setServername( r.getString(KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME, "") );
databaseMeta.setDataTablespace( r.getString(KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS, "") );
databaseMeta.setIndexTablespace( r.getString(KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS, "") );
// Also, load all the properties we can find...
final Collection<RowMetaAndData> attrs = repository.connectionDelegate.getDatabaseAttributes(id_database);
for (RowMetaAndData row : attrs)
{
String code = row.getString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_CODE, "");
String attribute = row.getString(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_VALUE_STR, "");
// System.out.println("Attributes: "+(getAttributes()!=null)+", code: "+(code!=null)+", attribute: "+(attribute!=null));
databaseMeta.getAttributes().put(code, Const.NVL(attribute, ""));
}
}
return databaseMeta;
}
catch(KettleDatabaseException dbe)
{
throw new KettleException("Error loading database connection from repository (id_database="+id_database+")", dbe);
}
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:59,代码来源:KettleDatabaseRepositoryDatabaseDelegate.java
示例2: saveDatabaseMeta
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
/**
* Saves the database information into a given repository.
*
* @param databaseMeta The database metadata object to store
*
* @throws KettleException if an error occurs.
*/
public void saveDatabaseMeta(DatabaseMeta databaseMeta) throws KettleException
{
try
{
// If we don't have an ID, we don't know which entry in the database we need to update.
// See if a database with the same name is already available...
if (databaseMeta.getObjectId()==null)
{
databaseMeta.setObjectId(getDatabaseID(databaseMeta.getName()));
}
// Still not found? --> Insert
if (databaseMeta.getObjectId()==null)
{
// Insert new Note in repository
//
databaseMeta.setObjectId(insertDatabase(databaseMeta.getName(),
databaseMeta.getPluginId(),
DatabaseMeta.getAccessTypeDesc(databaseMeta.getAccessType()),
databaseMeta.getHostname(),
databaseMeta.getDatabaseName(),
databaseMeta.getDatabasePortNumberString(),
databaseMeta.getUsername(),
databaseMeta.getPassword(),
databaseMeta.getServername(),
databaseMeta.getDataTablespace(),
databaseMeta.getIndexTablespace()
)
);
}
else // --> found entry with the same name...
{
// Update the note...
updateDatabase( databaseMeta.getObjectId(),
databaseMeta.getName(),
databaseMeta.getPluginId(),
DatabaseMeta.getAccessTypeDesc(databaseMeta.getAccessType()),
databaseMeta.getHostname(),
databaseMeta.getDatabaseName(),
databaseMeta.getDatabasePortNumberString(),
databaseMeta.getUsername(),
databaseMeta.getPassword(),
databaseMeta.getServername(),
databaseMeta.getDataTablespace(),
databaseMeta.getIndexTablespace()
);
}
// For the extra attributes, just delete them and re-add them.
delDatabaseAttributes(databaseMeta.getObjectId());
// OK, now get a list of all the attributes set on the database connection...
//
Properties attributes = databaseMeta.getAttributes();
Enumeration<Object> keys = databaseMeta.getAttributes().keys();
while (keys.hasMoreElements())
{
String code = (String) keys.nextElement();
String attribute = (String)attributes.get(code);
// Save this attribute
//
insertDatabaseAttribute(databaseMeta.getObjectId(), code, attribute);
}
}
catch(KettleDatabaseException dbe)
{
throw new KettleException("Error saving database connection or one of its attributes to the repository.", dbe);
}
}
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:78,代码来源:KettleDatabaseRepositoryDatabaseDelegate.java