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


Java SQLiteStatement类代码示例

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


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

示例1: processTuple

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的package包/类
@Override
public void processTuple(int tableNum, HashMap<String, Object> tuple)
{
  InputSchema inputSchema = inputSchemas.get(tableNum);

  SQLiteStatement insertStatement = insertStatements.get(tableNum);
  try {
    for (Map.Entry<String, Object> entry : tuple.entrySet()) {
      ColumnInfo t = inputSchema.columnInfoMap.get(entry.getKey());
      if (t != null && t.bindIndex != 0) {
        insertStatement.bind(t.bindIndex, entry.getValue().toString());
      }
    }

    insertStatement.step();
    insertStatement.reset();
  } catch (SQLiteException ex) {
    throw new RuntimeException(ex);
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:21,代码来源:SqliteStreamOperator.java

示例2: CardsManager

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的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

示例3: prepareStatement

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的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: longForQuery

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的package包/类
/**
 * Utility method to run the query on the db and return the value in the
 * first column of the first row.
 */
public static Long longForQuery(SQLiteConnection conn, String query, Object[] bindArgs)
        throws SQLiteException {
    SQLiteStatement stmt = null;
    try {
        stmt = conn.prepare(query);
        if (bindArgs != null && bindArgs.length > 0) {
            stmt = SQLiteWrapperUtils.bindArguments(stmt, bindArgs);
        }
        if (stmt.step()) {
            return stmt.columnLong(0);
        } else {
            throw new IllegalStateException("query failed to return any result: " + query);
        }
    } finally {
        SQLiteWrapperUtils.disposeQuietly(stmt);
    }
}
 
开发者ID:cloudant,项目名称:sync-android,代码行数:22,代码来源:SQLiteWrapperUtils.java

示例5: buildSQLiteCursor

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的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: AbstractSpectrumSliceIterator

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的package包/类
public AbstractSpectrumSliceIterator(
	AbstractSpectrumHeaderReader spectrumHeaderReader,
	AbstractDataEncodingReader dataEncodingReader,
	SQLiteConnection connection,
	String sqlQuery
) throws SQLiteException, StreamCorruptedException {
	
	// Create a new statement (will be automatically closed by the StatementIterator)
	SQLiteStatement stmt = connection.prepare(sqlQuery, true); // true = cached enabled

	// Set some fields
	this.boundingBoxIterator = new BoundingBoxIterator(
		spectrumHeaderReader,
		dataEncodingReader,
		connection,
		stmt
	);
	this.statement = stmt;

	initBB();
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:22,代码来源:AbstractSpectrumSliceIterator.java

示例7: createRunSlicesSubsetStatementBinder

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的package包/类
private static ISQLiteStatementConsumer createRunSlicesSubsetStatementBinder(
	final double minRunSliceMz,
	final double maxRunSliceMz
) {
	// Lambda require to catch Exceptions
	// For workarounds see: http://stackoverflow.com/questions/14039995/java-8-mandatory-checked-exceptions-handling-in-lambda-expressions-why-mandato	
	/*return rethrowConsumer( (stmt) -> {
		stmt.bind(1, 1); // Bind the msLevel
		stmt.bind(2, minRunSliceMz); // Bind the minRunSliceMz
		stmt.bind(3, maxRunSliceMz); // Bind the maxRunSliceMz
	});*/
	
	return new ISQLiteStatementConsumer() {
		public void accept(SQLiteStatement stmt) throws SQLiteException {
			stmt.bind(1, 1); // Bind the msLevel
			stmt.bind(2, minRunSliceMz); // Bind the minRunSliceMz
			stmt.bind(3, maxRunSliceMz); // Bind the maxRunSliceMz
		}
	};
}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:21,代码来源:LcMsRunSliceIterator.java

示例8: BoundingBoxIterator

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的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

示例9: extractObject

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的package包/类
public BoundingBox extractObject(SQLiteStatement stmt) throws SQLiteException, StreamCorruptedException {

		int bbId = stmt.columnInt(0);
		byte[] bbBytes = stmt.columnBlob(1);
		int runSliceId = stmt.columnInt(2);
		int firstSpectrumId = stmt.columnInt(3);
		int lastSpectrumId = stmt.columnInt(4);

		BoundingBox bb = BoundingBoxBuilder.buildBB(
			bbId,
			bbBytes,
			firstSpectrumId,
			lastSpectrumId,
			this.spectrumHeaderById,
			this.dataEncodingBySpectrumId
		);		
		bb.setRunSliceId(runSliceId);
		
		return bb;
	}
 
开发者ID:mzdb,项目名称:mzdb-access,代码行数:21,代码来源:BoundingBoxIterator.java

示例10: MsSpectrumRangeIteratorImpl

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的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

示例11: SpectrumIterator

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的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

示例12: loadStockSymbolsFromDB

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的package包/类
public Map<String, String> loadStockSymbolsFromDB() {
    Map<String, String> symbolsMap = new HashMap<String, String>();
    // Read symbols from database
    try {
        String command = "SELECT symbol,name FROM Symbols WHERE source=" + this.stockExchangeNumber + ";";
        String symbolStr;
        String nameStr;

        logger.logDB(command);
        SQLiteStatement st = db.prepare(command);
        while (st.step()) {
            symbolStr = st.columnString(0);
            nameStr = st.columnString(1);
            logger.log(symbolStr);
            symbolsMap.put(symbolStr, nameStr);
        }
    } catch (Exception e) {
        logger.logException(e);
    }
    return symbolsMap;
}
 
开发者ID:rrodrigoa,项目名称:SmartStocks,代码行数:22,代码来源:Controller.java

示例13: deleteDhcpLease

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的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

示例14: findDhcpLeasesForIA

import com.almworks.sqlite4java.SQLiteStatement; //导入依赖的package包/类
/**
 * Find dhcp leases for ia.
 *
 * @param duid the duid
 * @param iatype the iatype
 * @param iaid the iaid
 * @return the list
 */
protected List<DhcpLease> findDhcpLeasesForIA(final byte[] duid, final byte iatype, final long iaid)
{
	SQLiteConnection connection = null;
	SQLiteStatement statement = null;
	try {
		connection = getSQLiteConnection();
		statement = connection.prepare("select * from dhcplease" +
	                " where duid = ?" +
	                " and iatype = ?" +
	                " and iaid = ?");
		statement.bind(1, duid);
           statement.bind(2, iatype);
           statement.bind(3, iaid);			
           return mapLeases(statement);
	}
	catch (SQLiteException ex) {
		log.error("findDhcpLeasesForIA failed", ex);
		throw new RuntimeException(ex);
	}
	finally {
		closeStatement(statement);
		closeConnection(connection);
	}
}
 
开发者ID:jagornet,项目名称:dhcp,代码行数:33,代码来源:SqliteLeaseManager.java

示例15: deleteIaAddr

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


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