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


Java SQLiteConnection类代码示例

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


SQLiteConnection类属于com.almworks.sqlite4java包,在下文中一共展示了SQLiteConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: open

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public int open(final String path) {

      SQLiteConnection dbConnection = execute("open SQLite connection", new Callable<SQLiteConnection>() {
        @Override
        public SQLiteConnection call() throws Exception {
          SQLiteConnection connection = IN_MEMORY_PATH.equals(path)
              ? new SQLiteConnection()
              : new SQLiteConnection(new File(path));

          connection.open();

          return connection;
        }
      });

      int ptr = pointerCounter.incrementAndGet();
      connectionsMap.put(ptr, dbConnection);
      return ptr;
    }
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:20,代码来源:ShadowSQLiteConnection.java

示例3: prepareStatement

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public int prepareStatement(final int connectionPtr, final String sql) {
  // TODO: find a way to create collators
  if ("REINDEX LOCALIZED".equals(sql)) {
    return IGNORED_REINDEX_STMT;
  }

  SQLiteStatement stmt = execute("prepare statement", new Callable<SQLiteStatement>() {
    @Override
    public SQLiteStatement call() throws Exception {
      SQLiteConnection connection = getConnection(connectionPtr);
      return connection.prepare(sql);
    }
  });

  int pointer = pointerCounter.incrementAndGet();
  statementsMap.put(pointer, stmt);
  return pointer;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:19,代码来源:ShadowSQLiteConnection.java

示例4: checkCreateColumn

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
/**
 * Check if the column exists in the table, if yes, check the type, if no
 * create it with the appropriate type.
 * 
 * @param db
 * @param columnsInTable
 *            A Map containing all columns which exists in the table and
 *            their type.
 * @param tablename
 *            The table which should be checked
 * @param columnname
 *            The column in this table which should be checked
 * @param type
 *            The desired type of the column
 * @throws SQLiteException
 * @throws InconsistentTableException
 *             If the column already exists in the table but the type is
 *             wrong.
 */
private static void checkCreateColumn(SQLiteConnection db, Map<String, String> columnsInTable, String tablename, String columnname, String type)
		throws SQLiteException, InconsistentTableException
{
	String columnnameLower = columnname.toLowerCase();
	String typeUpper = type.toUpperCase();

	if (columnsInTable.containsKey(columnnameLower))
	{
		String actualType = columnsInTable.get(columnnameLower);
		if (!actualType.equals(typeUpper))
		{
			throw new InconsistentTableException("Column " + tablename + "." + columnname + " should be " + typeUpper + " but is " + actualType);
		}
	} else
	{
		LOGGER.debug("Create SQL %s", "ALTER TABLE " + tablename + " ADD COLUMN " + columnname + " " + typeUpper + " DEFAULT NULL;");
		db.exec("ALTER TABLE " + tablename + " ADD COLUMN " + columnname + " " + typeUpper + " DEFAULT NULL;");
	}
}
 
开发者ID:StoragePerformanceAnalyzer,项目名称:SPA,代码行数:39,代码来源:SQLiteHelper.java

示例5: buildSQLiteCursor

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public static SQLiteCursor buildSQLiteCursor(SQLiteConnection conn, String sql, Object[] bindArgs)
        throws SQLiteException {
    SQLiteStatement stmt = null;
    try {
        stmt = bindArguments(conn.prepare(sql), bindArgs);
        List<String> columnNames = null;
        List<Tuple> resultSet = new ArrayList<Tuple>();
        while (!stmt.hasStepped() || stmt.hasRow()) {
            if (!stmt.step()) {
                break;
            }
            if (columnNames == null) {
                columnNames = getColumnNames(stmt);
            }

            Tuple t = getDataRow(stmt);
            logger.finest("Tuple: "+ t.toString());
            resultSet.add(t);
        }
        return new SQLiteCursor(columnNames, resultSet);
    } finally {
        SQLiteWrapperUtils.disposeQuietly(stmt);
    }
}
 
开发者ID:cloudant,项目名称:sync-android,代码行数:25,代码来源:SQLiteWrapperUtils.java

示例6: SQLiteQuery

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public SQLiteQuery(SQLiteConnection connection, String sqlQuery, boolean cacheStmt)
		throws SQLiteException {
	super();

	this.queryString = sqlQuery;
	this.stmt = connection.prepare(sqlQuery, cacheStmt);

	HashMap<String, Integer> colIdxByColName = new HashMap<String, Integer>();

	int nbCols = stmt.columnCount();
	for (int colIdx = 0; colIdx < nbCols; colIdx++) {
		String colName = stmt.getColumnName(colIdx);
		colIdxByColName.put(colName, colIdx);
	}

	this.resultDesc = new SQLiteResultDescriptor(colIdxByColName);
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:18,代码来源:SQLiteQuery.java

示例7: getAcquisitionMode

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
/**
 * Lazy loading of the acquisition mode, parameter
 *
 * @return
 * @throws SQLiteException
 */
protected AcquisitionMode getAcquisitionMode(SQLiteConnection connection) throws SQLiteException {

	if (this.acquisitionMode == null) {
		/*
		 * final String sqlString = "SELECT param_tree FROM run"; final String runParamTree = new
		 * SQLiteQuery(connection, sqlString).extractSingleString(); final ParamTree runTree =
		 * ParamTreeParser.parseParamTree(runParamTree);
		 */

		List<Run> runs = this.getRuns();
		Run run0 = runs.get(0);
		final ParamTree runTree = run0.getParamTree(connection);

		try {
			final CVParam cvParam = runTree.getCVParam(CVEntry.ACQUISITION_PARAMETER);
			final String value = cvParam.getValue();
			this.acquisitionMode = AcquisitionMode.getAcquisitionMode(value);
		} catch (Exception e) {
			this.acquisitionMode = AcquisitionMode.UNKNOWN;
		}
	}

	return this.acquisitionMode;
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:31,代码来源:AbstractMzDbReader.java

示例8: getMsnXic

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
protected Peak[] getMsnXic(
	double parentMz,
	double fragmentMz,
	double fragmentMzTolInDa,
	float minRt,
	float maxRt,
	XicMethod method,
	SQLiteConnection connection) throws SQLiteException,
			StreamCorruptedException {

	final double minFragMz = fragmentMz - fragmentMzTolInDa;
	final double maxFragMz = fragmentMz + fragmentMzTolInDa;
	final float minRtForRtree = minRt >= 0 ? minRt : 0;
	final float maxRtForRtree = maxRt > 0 ? maxRt : MzDbReaderQueries.getLastTime(connection);

	SpectrumSlice[] spectrumSlices = this.getMsnSpectrumSlices(parentMz, minFragMz, maxFragMz, minRtForRtree, maxRtForRtree, connection);

	final double fragMzTolPPM = MsUtils.DaToPPM(fragmentMz, fragmentMzTolInDa);
	return this._spectrumSlicesToXIC(spectrumSlices, fragmentMz, fragMzTolPPM, method);
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:21,代码来源:AbstractMzDbReader.java

示例9: deleteAllIAs

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
/**
    * For unit tests only
    */
public void deleteAllIAs() {
	SQLiteConnection connection = null;
	SQLiteStatement statement = null;
	try {
		connection = getSQLiteConnection();
		connection.exec("delete from dhcplease");
	}
	catch (SQLiteException ex) {
		log.error("deleteAllIAs failed", ex);
		throw new RuntimeException(ex);
	}
	finally {
		closeStatement(statement);
		closeConnection(connection);
	}
}
 
开发者ID:jagornet,项目名称:dhcp,代码行数:20,代码来源:SqliteLeaseManager.java

示例10: getBoundingBoxMsLevel

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
/**
 * Gets the bounding box ms level.
 *
 * @param bbId
 *            the bb id
 * @return the bounding box ms level
 * @throws SQLiteException
 *             the sQ lite exception
 */
public static int getBoundingBoxMsLevel(int bbId, SQLiteConnection connection) throws SQLiteException {

	// FIXME: check that the mzDB file has the bounding_box_msn_rtree table
	String sqlString1 = "SELECT run_slice_id FROM bounding_box WHERE id = ?";
	int runSliceId = new SQLiteQuery(connection, sqlString1).bind(1, bbId).extractSingleInt();

	String sqlString2 = "SELECT ms_level FROM run_slice WHERE run_slice.id = ?";
	return new SQLiteQuery(connection, sqlString2).bind(1, runSliceId).extractSingleInt();

	/*
	 * String sqlString =
	 * "SELECT min_ms_level FROM bounding_box_msn_rtree WHERE bounding_box_msn_rtree.id = ?"; return new
	 * SQLiteQuery(connection, sqlString).bind(1, bbId).extractSingleInt();
	 */
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:25,代码来源:MzDbReaderQueries.java

示例11: canOpen

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
protected static boolean canOpen(Configuration conf,
        String input,
        ProviderProperties providerProperties) throws IOException
{
  MbVectorTilesSettings dbSettings = parseResourceName(input, conf, providerProperties);
  SQLiteConnection conn = null;
  try {
    conn = getDbConnection(dbSettings, conf);
    return true;
  }
  catch(IOException e) {
    log.info("Unable to open MB vector tiles database: " + dbSettings.getFilename(), e);
  }
  finally {
    if (conn != null) {
      conn.dispose();
    }
  }
  return false;
}
 
开发者ID:ngageoint,项目名称:mrgeo,代码行数:21,代码来源:MbVectorTilesDataProvider.java

示例12: getRunSliceIdsForMzRange

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
/**
 * Gets the run slice ids for mz range.
 *
 * @param minMz
 *            the min mz
 * @param maxMz
 *            the max mz
 * @param msLevel
 *            the ms level
 * @param connection
 *            the connection
 * @return the run slice ids for mz range
 * @throws SQLiteException
 *             the sQ lite exception
 */
protected int[] getRunSliceIdsForMzRange(double minMz, double maxMz, int msLevel, SQLiteConnection connection) throws SQLiteException {

	RunSliceHeader firstRunSlice = this.getRunSliceForMz(minMz, msLevel, connection);
	RunSliceHeader lastRunSlice = this.getRunSliceForMz(maxMz, msLevel, connection);
	double mzHeight = (msLevel == 1) ? this.getMzDbReader().getBBSizes().BB_MZ_HEIGHT_MS1 : this.getMzDbReader().getBBSizes().BB_MZ_HEIGHT_MSn;

	int bufferLength = 1 + (int) ((maxMz - minMz) / mzHeight);

	String queryStr = "SELECT id FROM run_slice WHERE ms_level = ? AND begin_mz >= ? AND end_mz <= ?";

	return new SQLiteQuery(connection, queryStr)
			.bind(1, msLevel)
			.bind(2, firstRunSlice.getBeginMz())
			.bind(3, lastRunSlice.getEndMz())
			.extractInts(bufferLength);
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:32,代码来源:AbstractRunSliceHeaderReader.java

示例13: LcMsRunSliceIterator

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public LcMsRunSliceIterator(
	AbstractMzDbReader mzDbReader,
	SQLiteConnection connection,
	double minRunSliceMz,
	double maxRunSliceMz
) throws SQLiteException, StreamCorruptedException {		
	// Set msLevel to 1
	super(
		mzDbReader.getRunSliceHeaderReader(),
		mzDbReader.getSpectrumHeaderReader(),
		mzDbReader.getDataEncodingReader(),
		connection,
		runSlicesSubsetSqlQuery,
		1,
		createRunSlicesSubsetStatementBinder(minRunSliceMz,maxRunSliceMz)
	);
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:18,代码来源:LcMsRunSliceIterator.java

示例14: BoundingBoxIterator

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public BoundingBoxIterator(
	AbstractSpectrumHeaderReader spectrumHeaderReader,
	AbstractDataEncodingReader dataEncodingReader,
	SQLiteConnection connection,
	SQLiteStatement stmt,
	int msLevel
) throws SQLiteException, StreamCorruptedException {
	super(stmt);
	
	if( msLevel == 1 ) this.spectrumHeaderById = spectrumHeaderReader.getMs1SpectrumHeaderById(connection);
	else if( msLevel == 2 ) this.spectrumHeaderById = spectrumHeaderReader.getMs2SpectrumHeaderById(connection);
	else if( msLevel == 3 ) this.spectrumHeaderById = spectrumHeaderReader.getMs3SpectrumHeaderById(connection);
	else throw new IllegalArgumentException("unsupported MS level: " + msLevel);
	
	this.dataEncodingBySpectrumId = dataEncodingReader.getDataEncodingBySpectrumId(connection);
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:17,代码来源:BoundingBoxIterator.java

示例15: MsSpectrumRangeIteratorImpl

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public MsSpectrumRangeIteratorImpl(AbstractMzDbReader mzDbReader, SQLiteConnection connection, final int msLevel) throws SQLiteException,
		StreamCorruptedException {
	//super(mzDbReader, sqlQuery, msLevel, rethrowConsumer( (stmt) -> stmt.bind(1, msLevel) ) ); // Bind msLevel
	super(
		mzDbReader.getSpectrumHeaderReader(),
		mzDbReader.getDataEncodingReader(),
		connection,
		sqlQuery,
		msLevel,
		new ISQLiteStatementConsumer() {
			public void accept(SQLiteStatement stmt) throws SQLiteException {
				stmt.bind(1, msLevel); // Bind msLevel
			}
		}
	);
	
	this.initSpectrumSliceBuffer();
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:19,代码来源:SpectrumRangeIterator.java


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