本文整理汇总了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);
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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
}
};
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}