本文整理汇总了Java中com.healthmarketscience.jackcess.Database.create方法的典型用法代码示例。如果您正苦于以下问题:Java Database.create方法的具体用法?Java Database.create怎么用?Java Database.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.healthmarketscience.jackcess.Database
的用法示例。
在下文中一共展示了Database.create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OpenFile
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
private boolean OpenFile() throws Exception
{
data.oneFileOpened=true;
String realFilename = environmentSubstitute(meta.getFilename());
if(log.isBasic())
logBasic(Messages.getString("AccessOutput.log.WritingToFile", realFilename));
FileObject fileObject = KettleVFS.getFileObject(realFilename);
File file = new File(KettleVFS.getFilename(fileObject));
// First open or create the access file
if (!file.exists())
{
if (meta.isFileCreated())
{
data.db = Database.create(file);
}
else
{
logError(Messages.getString("AccessOutput.InitError.FileDoesNotExist", realFilename));
return false;
}
}
else
{
data.db = Database.open(file);
}
// Add the filename to the result object...
//
if(meta.isAddToResultFiles())
{
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, fileObject, getTransMeta().getName(), toString());
resultFile.setComment("This file was created with an access output step");
addResultFile(resultFile);
}
return true;
}
示例2: OpenFile
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
private boolean OpenFile() throws Exception
{
data.oneFileOpened=true;
String realFilename = environmentSubstitute(meta.getFilename());
if(log.isBasic())
logBasic(BaseMessages.getString(PKG, "AccessOutput.log.WritingToFile", realFilename));
FileObject fileObject = KettleVFS.getFileObject(realFilename, getTransMeta());
File file = FileUtils.toFile(fileObject.getURL());
// First open or create the access file
if (!file.exists())
{
if (meta.isFileCreated())
{
data.db = Database.create(file);
}
else
{
logError(BaseMessages.getString(PKG, "AccessOutput.InitError.FileDoesNotExist", realFilename));
return false;
}
}
else
{
data.db = Database.open(file);
}
// Add the filename to the result object...
//
if(meta.isAddToResultFiles())
{
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, fileObject, getTransMeta().getName(), toString());
resultFile.setComment("This file was created with an access output step");
addResultFile(resultFile);
}
return true;
}
示例3: importFile
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
private boolean importFile(String sourceFilename, String delimiter,String targetFilename,
String tablename,LogWriter log,Result result,Job parentJob)
{
boolean retval=false;
try{
incrFilesToProcess();
File sourceDataFile = new File(sourceFilename);
File targetDbFile = new File(targetFilename);
// create database if needed
if(!targetDbFile.exists())
{
Database.create(targetDbFile);
log.logBasic(toString(),Messages.getString("JobEntryMSAccessBulkLoad.Log.DbCreated",targetFilename));
}else
{
// Database exists
Database db=Database.open(targetDbFile);
log.logBasic(toString(),Messages.getString("JobEntryMSAccessBulkLoad.Log.DbOpened",targetFilename));
// Let's check table
if(db.getTable(tablename)!=null)
{
log.logBasic(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Log.TableExists",tablename));
}
// close database
if(db!=null) db.close();
log.logBasic(toString(),Messages.getString("JobEntryMSAccessBulkLoad.Log.DbCosed",targetFilename));
}
// load data from file
Database.open(targetDbFile).importFile(tablename, sourceDataFile, delimiter);
log.logBasic(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Log.FileImported",sourceFilename, tablename,targetFilename));
// add filename to result filename
if(add_result_filenames)
addFileToResultFilenames(sourceFilename,log,result,parentJob);
retval=true;
}
catch ( Exception e )
{
log.logError(toString(), Messages.getString("JobEntryMSAccessBulkLoad.Error.LoadingDataToFile",
sourceFilename,targetFilename,e.getMessage()));
}
if(retval)
incrSuccess();
else
incrErrors();
return retval;
}
示例4: importFile
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
private boolean importFile(String sourceFilename, String delimiter,String targetFilename,
String tablename, Result result,Job parentJob)
{
boolean retval=false;
try{
incrFilesToProcess();
File sourceDataFile = new File(sourceFilename);
File targetDbFile = new File(targetFilename);
// create database if needed
if(!targetDbFile.exists())
{
Database.create(targetDbFile);
logBasic(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Log.DbCreated",targetFilename));
}else
{
// Database exists
Database db=Database.open(targetDbFile);
logBasic(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Log.DbOpened",targetFilename));
// Let's check table
if(db.getTable(tablename)!=null)
{
logBasic(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Log.TableExists",tablename));
}
// close database
if(db!=null) db.close();
logBasic(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Log.DbCosed",targetFilename));
}
// load data from file
Database.open(targetDbFile).importFile(tablename, sourceDataFile, delimiter);
logBasic(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Log.FileImported",sourceFilename, tablename,targetFilename));
// add filename to result filename
if(add_result_filenames)
addFileToResultFilenames(sourceFilename, result, parentJob);
retval=true;
}
catch ( Exception e )
{
logError(BaseMessages.getString(PKG, "JobEntryMSAccessBulkLoad.Error.LoadingDataToFile",
sourceFilename,targetFilename,e.getMessage()));
}
if(retval)
incrSuccess();
else
incrErrors();
return retval;
}
示例5: createDatabase
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
void createDatabase( File databaseFile ) throws IOException {
db = Database.create( databaseFile );
}
示例6: importFile
import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
private boolean importFile( String sourceFilename, String delimiter, String targetFilename, String tablename,
Result result, Job parentJob ) {
boolean retval = false;
try {
incrFilesToProcess();
File sourceDataFile = new File( sourceFilename );
File targetDbFile = new File( targetFilename );
// create database if needed
if ( !targetDbFile.exists() ) {
Database.create( targetDbFile );
logBasic( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.DbCreated", targetFilename ) );
} else {
// Database exists
Database db = Database.open( targetDbFile );
logBasic( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.DbOpened", targetFilename ) );
// Let's check table
if ( db.getTable( tablename ) != null ) {
logBasic( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.TableExists", tablename ) );
}
// close database
if ( db != null ) {
db.close();
}
logBasic( BaseMessages.getString( PKG, "JobEntryMSAccessBulkLoad.Log.DbCosed", targetFilename ) );
}
// load data from file
Database.open( targetDbFile ).importFile( tablename, sourceDataFile, delimiter );
logBasic( BaseMessages.getString(
PKG, "JobEntryMSAccessBulkLoad.Log.FileImported", sourceFilename, tablename, targetFilename ) );
// add filename to result filename
if ( add_result_filenames ) {
addFileToResultFilenames( sourceFilename, result, parentJob );
}
retval = true;
} catch ( Exception e ) {
logError( BaseMessages.getString(
PKG, "JobEntryMSAccessBulkLoad.Error.LoadingDataToFile", sourceFilename, targetFilename, e.getMessage() ) );
}
if ( retval ) {
incrSuccess();
} else {
incrErrors();
}
return retval;
}