当前位置: 首页>>代码示例>>Java>>正文


Java Database.open方法代码示例

本文整理汇总了Java中com.healthmarketscience.jackcess.Database.open方法的典型用法代码示例。如果您正苦于以下问题:Java Database.open方法的具体用法?Java Database.open怎么用?Java Database.open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.healthmarketscience.jackcess.Database的用法示例。


在下文中一共展示了Database.open方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
/**
 * Writes the XML serialization of the given SF DPH database
 * to standard out.
 */
public static void main (String[] args) throws IOException, ClassNotFoundException, SQLException {
    if (args.length != 2) {
        System.out.println(String.format("Usage: %s <access file> <sqlite file>", Main.class.getName()));
        System.exit(1);
    }

    /* Load the SQLite driver */
    Class.forName("org.sqlite.JDBC");

    /* Do the export */
    final AccessExporter exporter = new AccessExporter(Database.open(new File(args[0]), true));
    final Connection jdbc = DriverManager.getConnection("jdbc:sqlite:" + args[1]);
    exporter.export(jdbc);
}
 
开发者ID:tinogomes,项目名称:mdb-sqlite,代码行数:19,代码来源:Main.java

示例2: testExport

import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
@Test
   public void testExport () throws IOException, SQLException {
       final AccessExporter exporter = new AccessExporter(Database.open(ACCESS_DB, true));
       exporter.export(sqlite);

/* XXX: Test the results using JDBC */
   }
 
开发者ID:tinogomes,项目名称:mdb-sqlite,代码行数:8,代码来源:AccessExporterTests.java

示例3: 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;
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:39,代码来源:AccessOutput.java

示例4: export

import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public ActionForward export(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    InputStream inputStream =
            ExportParkingDataToAccessDatabaseDA.class.getClassLoader().getResourceAsStream("templates/Cartoes_XML.mdb");

    if (inputStream != null) {
        File temp = FileUtils.copyToTemporaryFile(inputStream);
        Database db = Database.open(temp, Boolean.FALSE, Boolean.TRUE);

        Table xml = db.getTable("XML");
        List<ParkingParty> parkingParties = getValidParkingParties();
        for (ParkingParty parkingParty : parkingParties) {
            Object[] newRow = new Object[28];
            fillInRow(parkingParty, newRow);
            xml.addRow(newRow);
        }

        response.setContentType("application/vnd.ms-access");
        response.setHeader("Content-disposition", "attachment; filename=Cartões_XML.mdb");
        final ServletOutputStream writer = response.getOutputStream();
        writer.write(Files.toByteArray(temp));
        writer.flush();
        writer.close();

        response.flushBuffer();
        inputStream.close();
    }
    return null;
}
 
开发者ID:ist-dsi-archive,项目名称:fenix-parking,代码行数:31,代码来源:ExportParkingDataToAccessDatabaseDA.java

示例5: renderReport

import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public void renderReport(File parkingDataFile) throws Exception {
    Database db = Database.open(parkingDataFile, Boolean.FALSE, Boolean.TRUE);
    Table xml = db.getTable("XML");
    List<ParkingParty> parkingParties = getValidParkingParties();
    final Date now = new DateTime().toDate();
    final Map<String, Integer> parkingGroupCodes = getParkingGroupCodes();
    for (ParkingParty parkingParty : parkingParties) {
        if (parkingParty.getCardNumber() != 0) {
            Object[] newRow = new Object[28];
            fillInRow(parkingParty, newRow, parkingGroupCodes, now);
            xml.addRow(newRow);
        }
    }
}
 
开发者ID:ist-dsi-archive,项目名称:fenix-parking,代码行数:15,代码来源:ParkingDataReportFile.java

示例6: 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;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:39,代码来源:AccessOutput.java

示例7: readFile

import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
/**
 * Read from MS-Access Database
 * @param filename Access file name (.mdb)
 * @param poems Out param
 */
public void readFile(String filename, Poems poems) {
    try {
        db_.load();
        try (Database mdb = Database.open(new File("G:\\Test\\Poem\\db.mdb"))) {
            Table tbAuthor = mdb.getTable("xiaozhuan");
            Table tbPoem = mdb.getTable("poem");
                        
            int curPos = 0;
            for (Map<String, Object> row : tbPoem) {
                //for (Entry<String, Object> item : row.entrySet()) {
                //    System.out.println(item.getKey() + " - " + item.getValue().toString());
                //}
                
                Poem p = new Poem();
                String content = row.get("neirong").toString();
                p.setContent(content);
                
                String id = row.get("id").toString();
                p.setoriginalId(id);
                
                poems_.addPoem(p);
                db_.addPoem(p);
                
                curPos++;
            }
        }
        db_.save();
        System.out.println("Read from db complete! Poems: " + poems_.getCount());           
    } catch (IOException ex) {
        org.pmw.tinylog.Logger.error(ex);
    }
}
 
开发者ID:rainrambler,项目名称:PoemStar,代码行数:38,代码来源:MdbReader.java

示例8: 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;
  }
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:57,代码来源:JobEntryMSAccessBulkLoad.java

示例9: JackcessConnection

import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
public JackcessConnection(String url, String user, String pass, boolean onlyNotEmpty)
        throws Exception {
    db = Database.open(new File(url.split(":")[ 1]));
    ignoreEmpty = onlyNotEmpty;
}
 
开发者ID:evolute-pt,项目名称:dbtransfer,代码行数:6,代码来源:JackcessConnection.java

示例10: 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;
  }
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:57,代码来源:JobEntryMSAccessBulkLoad.java

示例11: openDatabase

import com.healthmarketscience.jackcess.Database; //导入方法依赖的package包/类
void openDatabase( File databaseFile ) throws IOException {
  db = Database.open( databaseFile );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:4,代码来源:AccessOutputData.java

示例12: 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;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:55,代码来源:JobEntryMSAccessBulkLoad.java


注:本文中的com.healthmarketscience.jackcess.Database.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。