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


Java SQLiteConnection.open方法代码示例

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


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

示例1: CardsManager

import com.almworks.sqlite4java.SQLiteConnection; //导入方法依赖的package包/类
private CardsManager() throws SQLiteException {
	SQLiteConnection db = new SQLiteConnection(new File(YGOCoreMain.getConfigurator().getDataBasePath()));
	db.open(true);
	SQLiteStatement st = db.prepare("SELECT id, ot, alias, type, level, race, attribute, atk, def FROM datas");
	try {
		while(st.step()) {
			int id = st.columnInt(0);
			Card c = new Card(id, st.columnInt(1));
			c.alias = st.columnInt(2);
			c.setcode = st.columnInt(3);
			int levelinfo = st.columnInt(4);
			c.level = levelinfo & 0xff;
			c.lscale = (levelinfo >> 24) & 0xff;
			c.rscale = (levelinfo >> 16) & 0xff;
			c.race = st.columnInt(6);
			c.attr = st.columnInt(7);
			c.attack = st.columnInt(8);
			c.defense = st.columnInt(9);
			mCards.put(id, c);
		}
	} finally {
		st.dispose();
	}
	db.dispose();
	
}
 
开发者ID:garymabin,项目名称:JYGOServer,代码行数:27,代码来源:CardsManager.java

示例2: initialValue

import com.almworks.sqlite4java.SQLiteConnection; //导入方法依赖的package包/类
@Override
  protected SQLiteConnection initialValue() {
SQLiteConnection connection = new SQLiteConnection(DATABASE_FILE);
try {
	connection.open();
	log.debug("Created new SQLite connection: " + connection.toString());
}
catch (SQLiteException ex) {
	log.error("Failed to open connection: " + ex);
}
return connection;
  }
 
开发者ID:jagornet,项目名称:dhcp,代码行数:13,代码来源:SqliteLeaseManager.java

示例3: setup

import com.almworks.sqlite4java.SQLiteConnection; //导入方法依赖的package包/类
@Override
public void setup(OperatorContext context)
{
  db = new SQLiteConnection(new File("/tmp/sqlite.db"));
  java.util.logging.Logger.getLogger("com.almworks.sqlite4java").setLevel(java.util.logging.Level.SEVERE);
  SQLiteStatement st;

  try {
    db.open(true);
    // create the temporary tables here
    for (int i = 0; i < inputSchemas.size(); i++) {
      InputSchema inputSchema = inputSchemas.get(i);
      ArrayList<String> indexes = new ArrayList<String>();
      if (inputSchema == null || inputSchema.columnInfoMap.isEmpty()) {
        continue;
      }
      String columnSpec = "";
      String columnNames = "";
      String insertQuestionMarks = "";
      int j = 0;
      for (Map.Entry<String, ColumnInfo> entry : inputSchema.columnInfoMap.entrySet()) {
        if (!columnSpec.isEmpty()) {
          columnSpec += ",";
          columnNames += ",";
          insertQuestionMarks += ",";
        }
        columnSpec += entry.getKey();
        columnSpec += " ";
        columnSpec += entry.getValue().type;
        if (entry.getValue().isColumnIndex) {
          indexes.add(entry.getKey());
        }
        columnNames += entry.getKey();
        insertQuestionMarks += "?";
        entry.getValue().bindIndex = ++j;
      }
      String createTempTableStmt = "CREATE TEMP TABLE " + inputSchema.name + "(" + columnSpec + ")";
      st = db.prepare(createTempTableStmt);
      st.step();
      st.dispose();
      for (String index : indexes) {
        String createIndexStmt = "CREATE INDEX " + inputSchema.name + "_" + index + "_idx ON " + inputSchema.name + " (" + index + ")";
        st = db.prepare(createIndexStmt);
        st.step();
        st.dispose();
      }
      String insertStmt = "INSERT INTO " + inputSchema.name + " (" + columnNames + ") VALUES (" + insertQuestionMarks + ")";

      insertStatements.add(i, db.prepare(insertStmt));
      // We are calling "DELETE FROM" on the tables and because of the "truncate optimization" in sqlite, it should be fast.
      // See http://sqlite.org/lang_delete.html
      deleteStatements.add(i, db.prepare("DELETE FROM " + inputSchema.name));
    }
    beginStatement = db.prepare("BEGIN");
    commitStatement = db.prepare("COMMIT");
    execStatement = db.prepare(statement);
  } catch (SQLiteException ex) {
    throw new RuntimeException(ex);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:61,代码来源:SqliteStreamOperator.java

示例4: testEmptyResultSave

import com.almworks.sqlite4java.SQLiteConnection; //导入方法依赖的package包/类
@Test
public void testEmptyResultSave() throws SQLiteException
{
	SQLiteDataStore ds = new SQLiteDataStore(tempFile);
	ds.setupDataStore();
	ds.storeConfigurationRun("My First Identifier");

	IndependentVariablesOfFFSB expBenchVars = SBHModelFactory.eINSTANCE.createIndependentVariablesOfFFSB();
	expBenchVars.setReadPercentage(100);
	expBenchVars.setReadBlockSize(32);
	expBenchVars.setWriteBlockSize(64);
	expBenchVars.setFilesetSize(100);

	IndependentVariablesOfSut expSutVars = SBHModelFactory.eINSTANCE.createIndependentVariablesOfSut();
	expSutVars.setFileSystem(FileSystem.EXT4);
	expSutVars.setScheduler(Scheduler.NOOP);

	String hostId = String.format("hostId_%d", (int) (Math.random() * 1000));

	DependentVariables depVars = SBHModelFactory.eINSTANCE.createDependentVariables();
	depVars.setBenchmarkPrefix("ffsb");
	List<DependentVariables> resultList = Lists.newArrayList();
	resultList.add(depVars);

	ds.storeExperimentResults(0, hostId, "FFSBBenchmark", 1, "testID", expSutVars, expBenchVars, resultList);

	ds.finishConfigurationRun();
	ds.closeDataStore();

	// Check database contains row
	SQLiteConnection db = new SQLiteConnection(new File(tempFile));
	db.open(false);

	// Run-Table
	SQLiteStatement stmt = db.prepare("SELECT count(runId) FROM runs WHERE hostId=?;");
	stmt.bind(1, hostId);
	stmt.step();
	Assert.assertEquals(1, stmt.columnInt(0));
	stmt.dispose();

	// IndependentVars
	SQLiteStatement stmt2 = db.prepare("SELECT count(runId) FROM ffsbIndependentVars;");
	stmt2.step();
	Assert.assertEquals(1, stmt2.columnInt(0));
	stmt2.dispose();

	db.dispose();
}
 
开发者ID:StoragePerformanceAnalyzer,项目名称:SPA,代码行数:49,代码来源:SQLiteTest.java

示例5: connectToDB

import com.almworks.sqlite4java.SQLiteConnection; //导入方法依赖的package包/类
public Boolean connectToDB() {
    try {
        Boolean needToPopulateDBFile = false;

        File dbFile = new File(DB_NAME);
        logger.log("opening database file " + DB_NAME);
        if (dbFile.exists() == false) {
            logger.log("database file not found, will create one");
            dbFile.createNewFile();
            logger.log("database file created");
            needToPopulateDBFile = true;
        }
        db = new SQLiteConnection(dbFile);
        db.open(true);

        // Pre-populate Database with tables if database is not there
        if (needToPopulateDBFile) {
            logger.log("need to populate new database file");
            // Begin transaction
            String command = "BEGIN TRANSACTION;";
            logger.logDB(command);
            db.exec(command);

            command = "CREATE TABLE InfoSource(id INTEGER PRIMARY KEY, source TEXT);";
            logger.logDB(command);
            db.exec(command);

            command = "INSERT INTO InfoSource(id, source) VALUES (1, \"NASDAQ\");";
            logger.logDB(command);
            db.exec(command);

            command = "INSERT INTO InfoSource(id, source) VALUES (2, \"NYSE\");";
            logger.logDB(command);
            db.exec(command);

            command = "INSERT INTO InfoSource(id, source) VALUES (3, \"LON\");";
            logger.logDB(command);
            db.exec(command);

            command = "INSERT INTO InfoSource(id, source) VALUES (4, \"SWX\");";
            logger.logDB(command);
            db.exec(command);

            command = "INSERT INTO InfoSource(id, source) VALUES (5, \"INDEXES\");";
            logger.logDB(command);
            db.exec(command);
            
            command = "CREATE TABLE Symbols(id INTEGER PRIMARY KEY, source, symbol TEXT, name TEXT, UNIQUE(source, symbol) ON CONFLICT IGNORE, FOREIGN KEY(source) REFERENCES InfoSource(id));";
            logger.logDB(command);
            db.exec(command);

            // Pre-populate the stock exchange symbols

            // NASDAQ
            Map<String, String> stockSymbols = this.loadStockSymbolsFromFile();
            this.saveStockSymbolsToDB(stockSymbols);

            command = "END TRANSACTION;";
            logger.logDB(command);
            db.exec(command);
        }

    } catch (Exception e) {
        logger.logException(e);
        logger.logError("returning false on connectToDB");
        return false;
    }
    logger.logSuccess("return true on connectToDB");
    return true;
}
 
开发者ID:rrodrigoa,项目名称:SmartStocks,代码行数:71,代码来源:Controller.java


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