本文整理汇总了Java中com.almworks.sqlite4java.SQLiteStatement.columnInt方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteStatement.columnInt方法的具体用法?Java SQLiteStatement.columnInt怎么用?Java SQLiteStatement.columnInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.almworks.sqlite4java.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.columnInt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: intForQuery
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 int intForQuery(SQLiteConnection conn, String query, Object[] bindArgs) throws SQLiteException {
SQLiteStatement stmt = null;
try {
stmt = bindArguments(conn.prepare(query), bindArgs);
if (stmt.step()) {
return stmt.columnInt(0);
} else {
throw new IllegalStateException("query failed to return any result: " + query);
}
} finally {
SQLiteWrapperUtils.disposeQuietly(stmt);
}
}
示例4: getMzRange
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Gets the mz range.
*
* @param msLevel
* the ms level
* @return runSlice min mz and runSlice max mz
* @throws SQLiteException
* the sQ lite exception
*/
public static int[] getMzRange(int msLevel, SQLiteConnection connection) throws SQLiteException {
final SQLiteStatement stmt = connection.prepare("SELECT min(begin_mz), max(end_mz) FROM run_slice WHERE ms_level=?");
stmt.bind(1, msLevel);
stmt.step();
final int minMz = stmt.columnInt(0);
final int maxMz = stmt.columnInt(1);
stmt.dispose();
final int[] mzRange = { minMz, maxMz };
return mzRange;
}
示例5: getSplits
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
@Override
public List<InputSplit> getSplits(JobContext context) throws IOException, InterruptedException
{
zoomLevel = dbSettings.getZoom();
if (zoomLevel < 0) {
// Get the max zoom from the tile data
SQLiteConnection conn = null;
try {
conn = MbVectorTilesDataProvider.getDbConnection(dbSettings,
context.getConfiguration());
String query = "SELECT MAX(zoom_level) FROM tiles";
SQLiteStatement stmt = null;
try {
stmt = conn.prepare(query, false);
if (stmt.step()) {
zoomLevel = stmt.columnInt(0);
}
else {
throw new IOException("Unable to get the max zoom level of " + dbSettings.getFilename());
}
}
finally {
if (stmt != null) {
stmt.dispose();
}
}
}
catch(SQLiteException e) {
throw new IOException("Unable to query " + dbSettings.getFilename() + " for the max zoom level", e);
}
finally {
if (conn != null) {
conn.dispose();
}
}
}
long recordCount = getRecordCount(context.getConfiguration());
long recordsPerPartition = dbSettings.getTilesPerPartition();
long numPartitions = recordCount / recordsPerPartition;
if (numPartitions * recordsPerPartition < recordCount) {
numPartitions += 1;
}
List<InputSplit> splits = new ArrayList<InputSplit>();
for (int i=0; i < numPartitions; i++) {
MbVectorTilesInputSplit split = new MbVectorTilesInputSplit(i * recordsPerPartition, recordsPerPartition, zoomLevel);
splits.add(split);
}
return splits;
}
示例6: addFavorite
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Adds a {@link ChivServer} as a favorite server to the database.
*
* @param cs the {@link ChivServer} to add
* @see SQLiteConnection
* @see SQLiteStatement
* @see SQLiteException
*/
public void addFavorite(ChivServer cs) {
printlnMC("Adding server to favorites...");
SQLiteConnection db = new SQLiteConnection(new File("browserdb"));
try {
db.open(true);
SQLiteStatement st = db.prepare("CREATE TABLE IF NOT EXISTS favorite_servers" +
"(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name varchar(255) not null default ''," +
"ip varchar(255) not null default ''," +
"port varchar(255) not null default '' )");
try {
st.step();
} finally {
st.dispose();
}
//check if exists
int id = -1;
st = db.prepare("SELECT id FROM favorite_servers WHERE ip = '" + cs.mIP + "' AND port = '" + cs.mQueryPort + "'");
try {
st.step();
if ( st.hasRow() ) {
id = st.columnInt(0);
}
} finally {
st.dispose();
}
if ( id > -1 ) {
printlnMC("Server already a favorite.");
st = db.prepare("INSERT OR REPLACE INTO favorite_servers (id, name, ip, port) " +
"VALUES ( " + id + ",'" + cs.mName + "', '" + cs.mIP + "', '" + cs.mQueryPort + "' )");
try {
st.step();
} finally {
st.dispose();
}
} else {
st = db.prepare("INSERT INTO favorite_servers (name, ip, port) " +
"VALUES ('" + cs.mName + "', '" + cs.mIP + "', '" + cs.mQueryPort + "' )");
try {
st.step();
} finally {
st.dispose();
}
printlnMC("Added to favorites: " + cs.mName);
}
} catch (SQLiteException e) {
e.printStackTrace();
}
db.dispose();
}
示例7: removeFavorite
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Removes a {@link ChivServer} from the favorites database.
*
* @param cs the {@link ChivServer} to remove
* @return if the server was successfully found and removed
* @see SQLiteConnection
* @see SQLiteStatement
* @see SQLiteException
*/
public boolean removeFavorite(ChivServer cs) {
boolean removed = false;
System.out.println("Removing from favorites...");
printlnMC("Removing server from favorites...");
SQLiteConnection db = new SQLiteConnection(new File("browserdb"));
try {
db.open(true);
SQLiteStatement st = db.prepare("CREATE TABLE IF NOT EXISTS favorite_servers" +
"(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name varchar(255) not null default ''," +
"ip varchar(255) not null default ''," +
"port varchar(255) not null default '' )");
try {
st.step();
} finally {
st.dispose();
}
//check if exists
int id = -1;
st = db.prepare("SELECT id FROM favorite_servers WHERE ip = '" + cs.mIP + "' AND port = '" + cs.mQueryPort + "'");
try {
st.step();
if ( st.hasRow() ) {
id = st.columnInt(0);
}
} finally {
st.dispose();
}
if ( id > -1 ) {
st = db.prepare("DELETE FROM favorite_servers WHERE id = " + id);
try {
st.step();
for ( int i=0; i<serversFav.size(); i++ ) {
ChivServer c = serversFav.get(i);
if ( cs.mIP.equals(c.mIP) && cs.mQueryPort.equals(c.mQueryPort) ) {
serversFav.remove(i);
break;
}
}
printlnMC("Removed favorite: " + cs.mName);
removed = true;
} finally {
st.dispose();
}
} else {
printlnMC("Didn't find server in database. This is probably a bad thing.");
}
} catch (SQLiteException e) {
e.printStackTrace();
}
db.dispose();
return removed;
}
示例8: addServerToHistory
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Adds a {@link ChivServer} to the server history database. This is typically called
* when the user joins a server.
*
* @param cs the {@link ChivServer} to add
* @see SQLiteConnection
* @see SQLiteStatement
* @see SQLiteException
*/
public void addServerToHistory(ChivServer cs) {
System.out.println("Adding server to history list.");
SQLiteConnection db = new SQLiteConnection(new File("browserdb"));
try {
db.open(true);
SQLiteStatement st = db.prepare("CREATE TABLE IF NOT EXISTS server_history" +
"(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name varchar(255) not null default ''," +
"ip varchar(255) not null default ''," +
"port varchar(255) not null default '' )");
try {
st.step();
} finally {
st.dispose();
}
//check if exists
int id = -1;
st = db.prepare("SELECT id FROM server_history WHERE ip = '" + cs.mIP + "' AND port = '" + cs.mQueryPort + "'");
try {
st.step();
if ( st.hasRow() ) {
id = st.columnInt(0);
}
} finally {
st.dispose();
}
if ( id > -1 ) {
st = db.prepare("INSERT OR REPLACE INTO server_history (id, name, ip, port) " +
"VALUES ( " + id + ",'" + cs.mName + "', '" + cs.mIP + "', '" + cs.mQueryPort + "' )");
try {
st.step();
} finally {
st.dispose();
}
} else {
st = db.prepare("INSERT INTO server_history (name, ip, port) " +
"VALUES ('" + cs.mName + "', '" + cs.mIP + "', '" + cs.mQueryPort + "' )");
try {
st.step();
} finally {
st.dispose();
}
}
} catch (SQLiteException e) {
e.printStackTrace();
}
db.dispose();
}
示例9: removeServerFromHistory
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Removes a {@link ChivServer} from the history database.
*
* @param cs the {@link ChivServer} to remove
* @return if the {@link ChivServer} was successfully found and removed
* @see SQLiteConnection
* @see SQLiteStatement
* @see SQLiteException
*/
public boolean removeServerFromHistory(ChivServer cs) {
boolean removed = false;
System.out.println("Removing from history...");
printlnMC("Removing server from history...");
SQLiteConnection db = new SQLiteConnection(new File("browserdb"));
try {
db.open(true);
SQLiteStatement st = db.prepare("CREATE TABLE IF NOT EXISTS server_history" +
"(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"name varchar(255) not null default ''," +
"ip varchar(255) not null default ''," +
"port varchar(255) not null default '' )");
try {
st.step();
} finally {
st.dispose();
}
//check if exists
int id = -1;
st = db.prepare("SELECT id FROM server_history WHERE ip = '" + cs.mIP + "' AND port = '" + cs.mQueryPort + "'");
try {
st.step();
if ( st.hasRow() ) {
id = st.columnInt(0);
}
} finally {
st.dispose();
}
if ( id > -1 ) {
st = db.prepare("DELETE FROM server_history WHERE id = " + id);
try {
st.step();
for ( int i=0; i<serversFav.size(); i++ ) {
ChivServer c = serversFav.get(i);
if ( cs.mIP.equals(c.mIP) && cs.mQueryPort.equals(c.mQueryPort) ) {
serversFav.remove(i);
break;
}
}
printlnMC("Removed history: " + cs.mName);
removed = true;
} finally {
st.dispose();
}
} else {
printlnMC("Didn't find server in database. This is probably a bad thing.");
}
} catch (SQLiteException e) {
e.printStackTrace();
}
db.dispose();
return removed;
}