• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SQLiteConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: SpectrumIterator

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public SpectrumIterator(AbstractMzDbReader mzDbReader, SQLiteConnection connection, final int msLevel) throws SQLiteException, StreamCorruptedException {
	//super(inst, sqlQuery, msLevel, rethrowConsumer( (stmt) -> stmt.bind(1, msLevel) ) ); // Bind msLevel
	super(
		mzDbReader.getSpectrumHeaderReader(),
		mzDbReader.getDataEncodingReader(),
		connection,
		singleMsLevelSqlQuery,
		msLevel,
		new ISQLiteStatementConsumer() {
			public void accept(SQLiteStatement stmt) throws SQLiteException {
				stmt.bind(1, msLevel); // Bind msLevel
			}
		}
	);
	
	this.usePriorityQueue = false;
	this.priorityQueue = null;

	this.initSpectrumSliceBuffer();
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:21,代码来源:SpectrumIterator.java


示例17: findExpiredLeases

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
protected List<DhcpLease> findExpiredLeases(final byte iatype) {
	SQLiteConnection connection = null;
	SQLiteStatement statement = null;
	try {
		connection = getSQLiteConnection();
		statement = connection.prepare(
	                "select * from dhcplease" +
	                " where iatype = ?" +
	                " and state != " + IaAddress.STATIC +
	                " and validendtime < ? order by validendtime");
		statement.bind(1, iatype);
		statement.bind(2, new Date().getTime());
		
		return mapLeases(statement);
	}
	catch (SQLiteException ex) {
		log.error("findExpiredLeases failed", ex);
		throw new RuntimeException(ex);
	}
	finally {
		closeStatement(statement);
		closeConnection(connection);
	}
}
 
开发者ID:jagornet,项目名称:dhcp,代码行数:25,代码来源:SqliteLeaseManager.java


示例18: deleteDhcpLease

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
/**
 * Delete dhcp lease.
 *
 * @param lease the lease
 */
protected void deleteDhcpLease(final DhcpLease lease)
{
	SQLiteConnection connection = null;
	SQLiteStatement statement = null;
	try {
		connection = getSQLiteConnection();
		statement = connection.prepare("delete from dhcplease" +
				 	" where ipaddress=?");
		statement.bind(1, lease.getIpAddress().getAddress());
		
		while (statement.step()) {
			log.debug("deleteDhcpLease: step=true");
		}
	}
	catch (SQLiteException ex) {
		log.error("deleteDhcpLease failed", ex);
		throw new RuntimeException(ex);
	}
	finally {
		closeStatement(statement);
		closeConnection(connection);
	}
}
 
开发者ID:jagornet,项目名称:dhcp,代码行数:29,代码来源:SqliteLeaseManager.java


示例19: setupDependentTables

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
/**
 * Does the job explained above for one BenchmarkDriver (for the dependent
 * variables).
 * 
 * @param db
 *            SQLite database which stores the tables
 * @param benchVars
 *            A EMF-Eclass describing the independent variables for the
 *            specific benchmark driver specific benchmark driver
 * @throws SQLiteException
 */
private void setupDependentTables(SQLiteConnection db, DependentVariables benchVars) throws SQLiteException
{
	String prefix = benchVars.getBenchmarkPrefix();

	// Construct queries for insertion of dependent variables.
	StringBuilder dvSql = new StringBuilder("INSERT INTO " + prefix + "DependentVars (runId, ");
	dvSql.append("benchPrefix");
	dvSql.append(") VALUES (?, ?");
	dvSql.append(");");

	// Rembemeber the statements for later use when values should be
	// inserted
	dvStmnts.put(prefix + "_first", db.prepare(dvSql.toString()));

	LOGGER.debug("SQL for prefix %s=%s", prefix + "_first", dvSql.toString());

	dvSql = new StringBuilder("INSERT INTO " + prefix + "DependentVarsValues (dvId, ");
	dvSql.append("operation, opMetric, opValue, opTimestamp, opType");
	dvSql.append(") VALUES (?, ?, ?, ?, ?, ?");
	dvSql.append(");");

	dvStmnts.put(prefix + "_second", db.prepare(dvSql.toString()));

	LOGGER.debug("SQL for prefix %s=%s", prefix + "_second", dvSql.toString());
}
 
开发者ID:StoragePerformanceAnalyzer,项目名称:SPA,代码行数:37,代码来源:SQLiteHelper.java


示例20: getConnection

import com.almworks.sqlite4java.SQLiteConnection; //导入依赖的package包/类
public SQLiteConnection getConnection(final int pointer) {
  SQLiteConnection connection = connectionsMap.get(pointer);
  if (connection == null) {
    throw new IllegalStateException("Illegal connection pointer " + pointer
        + ". Current pointers for thread " + Thread.currentThread() + " " + connectionsMap.keySet());
  }
  return connection;
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:9,代码来源:ShadowSQLiteConnection.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WhirlpoolDigest类代码示例发布时间:2022-05-22
下一篇:
Java Klass类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap