本文整理汇总了Java中com.almworks.sqlite4java.SQLiteStatement.bind方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteStatement.bind方法的具体用法?Java SQLiteStatement.bind怎么用?Java SQLiteStatement.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.almworks.sqlite4java.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.bind方法的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: findExpiredIaPrefixes
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
@Override
public List<IaPrefix> findExpiredIaPrefixes() {
SQLiteConnection connection = null;
SQLiteStatement statement = null;
try {
connection = getSQLiteConnection();
statement = connection.prepare(
"select * from dhcplease" +
" where iatype = " + IdentityAssoc.PD_TYPE +
" and validendtime < ? order by validendtime");
statement.bind(1, new Date().getTime());
List<DhcpLease> leases = mapLeases(statement);
return toIaPrefixes(leases);
}
catch (SQLiteException ex) {
log.error("findExpiredIaPrefixes failed", ex);
throw new RuntimeException(ex);
}
finally {
closeStatement(statement);
closeConnection(connection);
}
}
示例3: 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);
}
}
示例4: 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
}
};
}
示例5: 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);
}
}
示例6: 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();
}
示例7: 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);
}
}
示例8: bindParameters
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
private void bindParameters(SQLiteStatement st, List<Object> parameters) throws SQLiteException {
if (parameters != null) {
int size = parameters.size();
for (int i = 1; i <= size; i++) {
int key = i;
Object val = parameters.get(i);
Class<? extends Object> valType = val.getClass();
if (Integer.class.equals(valType)) {
st.bind(key, (Integer) val);
} else if (Double.class.equals(valType)) {
st.bind(key, (Double) val);
} else if (String.class.equals(valType)) {
st.bind(key, (String) val);
} else if (Long.class.equals(valType)) {
st.bind(key, (Long) val);
}
}
}
}
示例9: findExistingIPs
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
@Override
public List<InetAddress> findExistingIPs(final InetAddress startAddr, final InetAddress endAddr)
{
List<InetAddress> inetAddrs = new ArrayList<InetAddress>();
SQLiteConnection connection = null;
SQLiteStatement statement = null;
try {
connection = getSQLiteConnection();
statement = connection.prepare(
"select ipaddress from dhcplease" +
" where ipaddress >= ? and ipaddress <= ?" +
" order by ipaddress");
statement.bind(1, startAddr.getAddress());
statement.bind(2, endAddr.getAddress());
while (statement.step()) {
InetAddress inetAddr = null;
try {
inetAddr = InetAddress.getByAddress(statement.columnBlob(0));
}
catch (UnknownHostException e) {
throw new RuntimeException("Unable to map ipaddress", e);
}
inetAddrs.add(inetAddr);
}
return inetAddrs;
}
catch (SQLiteException ex) {
log.error("findExistingIPs failed", ex);
throw new RuntimeException(ex);
}
finally {
closeStatement(statement);
closeConnection(connection);
}
}
示例10: LcMsnRunSliceIterator
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
public LcMsnRunSliceIterator(
AbstractMzDbReader mzDbReader,
SQLiteConnection connection,
final double minParentMz,
final double maxParentMz
) throws SQLiteException, StreamCorruptedException {
/*super(mzDbReader, allRunSlicesSqlQuery, 2, rethrowConsumer( (stmt) -> {
// Lambda require to catch Exceptions
// For workarounds see: http://stackoverflow.com/questions/14039995/java-8-mandatory-checked-exceptions-handling-in-lambda-expressions-why-mandato
stmt.bind(1, 2); // Bind the msLevel
stmt.bind(2, minParentMz); // Bind the minParentMz
stmt.bind(3, maxParentMz); // Bind the maxParentMz
}) );*/
// Set msLevel to 2
// FIXME: what about msLevel > 2 ?
super(
mzDbReader.getRunSliceHeaderReader(),
mzDbReader.getSpectrumHeaderReader(),
mzDbReader.getDataEncodingReader(),
connection,
sameIsolationWindowRunSlicesSqlQuery,
2,
new ISQLiteStatementConsumer() {
public void accept(SQLiteStatement stmt) throws SQLiteException {
stmt.bind(1, 2); // Bind the msLevel
stmt.bind(2, minParentMz); // Bind the minParentMz
stmt.bind(3, maxParentMz); // Bind the maxParentMz
}
}
);
}
示例11: bind
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Binds a Object to a SQLiteStatement. The right {@code bind} method of the
* {@code SQLiteStatement} has to be used because otherwise the type is not
* preserved.
*
* @param stmt
* @param idx
* @param o
* @throws SQLiteException
*/
private static void bind(SQLiteStatement stmt, int idx, Object o) throws SQLiteException
{
if (o == null)
{
stmt.bindNull(idx);
} else if (o instanceof Double)
{
stmt.bind(idx, (Double) o);
} else if (o instanceof String)
{
stmt.bind(idx, (String) o);
} else if (o instanceof Integer)
{
stmt.bind(idx, (Integer) o);
} else if (o instanceof Long)
{
stmt.bind(idx, (Long) o);
} else if (o instanceof Boolean)
{
stmt.bind(idx, (Boolean) o == Boolean.TRUE ? 1 : 0);
} else if (o instanceof Enumerator)
{
// ECore EEnum
stmt.bind(idx, ((Enumerator) o).getLiteral());
} else if (o instanceof Timestamp)
{
stmt.bind(idx, ((Timestamp) o).getTime());
} else if (o instanceof File)
{
stmt.bind(idx, ((File) o).getAbsolutePath());
} else if (o instanceof Integer)
{
stmt.bind(idx, (Integer) o);
} else
{
throw new IllegalArgumentException("Could not bind Object " + o);
}
}
示例12: getRecordCount
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
protected long getRecordCount(Configuration conf) throws IOException
{
String countQuery = "SELECT COUNT(*) FROM tiles WHERE zoom_level=?";
// Run the count query and grab the result.
SQLiteConnection conn = null;
try {
conn = MbVectorTilesDataProvider.getDbConnection(dbSettings, conf);
SQLiteStatement stmt = null;
try {
stmt = conn.prepare(countQuery, false);
stmt.bind(1, zoomLevel);
if (stmt.step()) {
return stmt.columnLong(0);
}
else {
throw new IOException("Unable to count tiles for zoom " + zoomLevel + " in " + dbSettings.getFilename());
}
}
finally {
if (stmt != null) {
stmt.dispose();
}
}
}
catch (SQLiteException e)
{
String msg = "Unable to get the count of records using query: " + countQuery;
log.error(msg, e);
throw new IOException(msg, e);
}
finally {
if (conn != null) {
conn.dispose();
}
}
}
示例13: insertDhcpLease
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Insert dhcp lease.
*
* @param lease the lease
*/
protected void insertDhcpLease(final DhcpLease lease)
{
SQLiteConnection connection = null;
SQLiteStatement statement = null;
try {
connection = getSQLiteConnection();
statement = connection.prepare("insert into dhcplease" +
" (ipaddress, duid, iatype, iaid, prefixlen, state," +
" starttime, preferredendtime, validendtime," +
" ia_options, ipaddr_options)" +
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
statement.bind(1, lease.getIpAddress().getAddress());
statement.bind(2, lease.getDuid());
statement.bind(3, lease.getIatype());
statement.bind(4, lease.getIaid());
statement.bind(5, lease.getPrefixLength());
statement.bind(6, lease.getState());
statement.bind(7, lease.getStartTime().getTime());
statement.bind(8, lease.getPreferredEndTime().getTime());
statement.bind(9, lease.getValidEndTime().getTime());
statement.bind(10, encodeOptions(lease.getIaDhcpOptions()));
statement.bind(11, encodeOptions(lease.getIaAddrDhcpOptions()));
while (statement.step()) {
log.debug("insertDhcpLease: step=true");
}
}
catch (SQLiteException ex) {
log.error("insertDhcpLease failed", ex);
throw new RuntimeException(ex);
}
finally {
closeStatement(statement);
closeConnection(connection);
}
}
示例14: updateDhcpLease
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Update dhcp lease.
*
* @param lease the lease
*/
protected void updateDhcpLease(final DhcpLease lease)
{
SQLiteConnection connection = null;
SQLiteStatement statement = null;
try {
connection = getSQLiteConnection();
statement = connection.prepare("update dhcplease" +
" set state=?," +
" starttime=?," +
" preferredendtime=?," +
" validendtime=?," +
" ia_options=?," +
" ipaddr_options=?" +
" where ipaddress=?");
statement.bind(1, lease.getState());
statement.bind(2, lease.getStartTime().getTime());
statement.bind(3, lease.getPreferredEndTime().getTime());
statement.bind(4, lease.getValidEndTime().getTime());
statement.bind(5, encodeOptions(lease.getIaDhcpOptions()));
statement.bind(6, encodeOptions(lease.getIaAddrDhcpOptions()));
statement.bind(7, lease.getIpAddress().getAddress());
while (statement.step()) {
log.debug("updateDhcpLease: step=true");
}
}
catch (SQLiteException ex) {
log.error("updateDhcpLease failed", ex);
throw new RuntimeException(ex);
}
finally {
closeStatement(statement);
closeConnection(connection);
}
}
示例15: updateIaOptions
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Update ia options.
*/
protected void updateIaOptions(final InetAddress inetAddr,
final Collection<DhcpOption> iaOptions)
{
SQLiteConnection connection = null;
SQLiteStatement statement = null;
try {
connection = getSQLiteConnection();
statement = connection.prepare("update dhcplease" +
" set ia_options=?" +
" where ipaddress=?");
statement.bind(1, encodeOptions(iaOptions));
statement.bind(2, inetAddr.getAddress());
while (statement.step()) {
log.debug("updateIaOptions: step=true");
}
}
catch (SQLiteException ex) {
log.error("updateIaOptions failed", ex);
throw new RuntimeException(ex);
}
finally {
closeStatement(statement);
closeConnection(connection);
}
}