本文整理汇总了Java中com.almworks.sqlite4java.SQLiteStatement.columnString方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteStatement.columnString方法的具体用法?Java SQLiteStatement.columnString怎么用?Java SQLiteStatement.columnString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.almworks.sqlite4java.SQLiteStatement
的用法示例。
在下文中一共展示了SQLiteStatement.columnString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: queryOneString
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
public String queryOneString(String sql, List<Object> parameters){
SQLiteStatement st = null;
try {
st = db.prepare(sql);
bindParameters(st, parameters);
if (st.step()) {
return st.columnString(0);
}
return null;
} catch (SQLiteException e) {
e.printStackTrace();
return null;
} finally {
if (st != null) {
st.dispose();
}
}
}
示例3: queryOneString
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
public String queryOneString(SQLiteConnection db,String sql, List<Object> parameters){
SQLiteStatement st = null;
try {
st = db.prepare(sql);
bindParameters(st, parameters);
if (st.step()) {
return st.columnString(0);
}
return null;
} catch (SQLiteException e) {
e.printStackTrace();
return null;
} finally {
if (st != null) {
st.dispose();
}
}
}
示例4: getFavorites
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Gets favorite servers from the local database.
*
* @return a {@link Vector} of the {@link ChivServer}
* @see ChivServer
* @see SQLiteConnection
* @see SQLiteStatement
* @see SQLiteException
*/
public Vector<ChivServer> getFavorites() {
Vector<ChivServer> serversFav = new Vector<ChivServer>();
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();
}
st = db.prepare("SELECT * FROM favorite_servers");
try {
while (st.step()) {
String name = st.columnString(1);
String ip = st.columnString(2);
String queryport = st.columnString(3);
serversFav.add(new ChivServer(name, ip, queryport));
}
} finally {
st.dispose();
}
} catch (SQLiteException e) {
e.printStackTrace();
}
db.dispose();
return serversFav;
}
示例5: getServerFromDB
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Searches the database for a server matching the ip address and gameport to find the
* associated queryport.
*
* @param ip the ip address of the server
* @param gameport the gameport of the server
* @return returns the {@link ChivServer}; or null if not found
* @see SQLiteConnection
* @see SQLiteStatement
* @see SQLiteException
*/
public ChivServer getServerFromDB(String ip, String gameport) {
String queryport = "";
SQLiteConnection db = new SQLiteConnection(new File("browserdb"));
try {
db.open(true);
SQLiteStatement st = db.prepare("CREATE TABLE IF NOT EXISTS servers" +
"(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"ip varchar(255) not null default ''," +
"queryport varchar(255) not null default ''," +
"gameport varchar(255) not null default ''" +
")");
try {
st.step();
} finally {
st.dispose();
}
st = db.prepare("SELECT queryport FROM servers WHERE ip = '" + ip + "' AND gameport = '" + gameport + "'");
try {
st.step();
if ( st.hasRow() ) {
queryport = st.columnString(0);
}
} finally {
st.dispose();
}
} catch (SQLiteException e) {
e.printStackTrace();
}
db.dispose();
if ( !queryport.equals("") ) {
return ChivServer.createChivServer(mw, ip, Integer.parseInt(queryport));
}
return null;
}
示例6: getHistory
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Gets server history from the local database.
*
* @return a {@link Vector} of the {@link ChivServer}
* @see ChivServer
* @see SQLiteConnection
* @see SQLiteStatement
* @see SQLiteException
*/
public Vector<ChivServer> getHistory() {
Vector<ChivServer> serversHist = new Vector<ChivServer>();
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();
}
st = db.prepare("SELECT * FROM server_history");
try {
while (st.step()) {
String name = st.columnString(1);
String ip = st.columnString(2);
String queryport = st.columnString(3);
serversHist.add(new ChivServer(name, ip, queryport));
}
} finally {
st.dispose();
}
} catch (SQLiteException e) {
e.printStackTrace();
}
db.dispose();
return serversHist;
}
示例7: saveDependentVars
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Save the dependent variables of a run in the appropriate table. There can
* be zero or more results which should be saved.
*
* @param runId
* @param depVars
* @throws SQLiteException
*/
public void saveDependentVars(long runId, List<DependentVariables> depVarsList, SQLiteConnection db) throws SQLiteException
{
String prefix = depVarsList.get(0).getBenchmarkPrefix();
SQLiteStatement stmt = dvStmnts.get(prefix + "_first");
int paramNo = 0;
stmt.bind(++paramNo, runId);
stmt.bind(++paramNo, depVarsList.get(0).getBenchmarkPrefix());
stmt.step();
stmt.reset();
SQLiteStatement sIndex = db.prepare("SELECT last_insert_rowid() FROM " + prefix + "DependentVars");
sIndex.step();
String dvId = sIndex.columnString(0);
sIndex.dispose();
for (int j = 0; j < depVarsList.size(); ++j)
{
DependentVariables depVars = depVarsList.get(j);
for (int i = 0; i < depVars.getValues().size(); ++i)
{
stmt = dvStmnts.get(prefix + "_second");
paramNo = 0;
stmt.bind(++paramNo, dvId);
stmt.bind(++paramNo, depVars.getValues().get(i).getOperation());
stmt.bind(++paramNo, depVars.getValues().get(i).getOperationMetric().getValue());
stmt.bind(++paramNo, depVars.getValues().get(i).getValue());
stmt.bind(++paramNo, depVars.getValues().get(i).getSource());
if (depVars.getValues().get(i) instanceof DependentVariablesValueSingle)
{
//System.out.println(depVars.getValues().get(i));
stmt.bind(++paramNo, ((DependentVariablesValueSingle) depVars.getValues().get(i)).getTimestamp());
stmt.bind(++paramNo, Type.SINGLE_VALUE_VALUE);
} else if (depVars.getValues().get(i) instanceof DependentVariablesValueComposite)
{
//System.out.println(depVars.getValues().get(i));
stmt.bind(++paramNo, "");
stmt.bind(++paramNo, ((DependentVariablesValueComposite) depVars.getValues().get(i)).getType().getValue());
}
stmt.step();
stmt.reset();
}
LOGGER.trace("Finished Saving Dependent Vars %s", depVars);
}
}
示例8: saveDependentVars
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
/**
* Save the dependent variables of a run in the appropriate table. There can
* be zero or more results which should be saved.
*
* @param runId
* @param depVars
* @throws SQLiteException
*/
public void saveDependentVars(long runId, List<DependentVariables> depVarsList, SQLiteConnection db) throws SQLiteException
{
String prefix = depVarsList.get(0).getBenchmarkPrefix();
SQLiteStatement stmt = dvStmnts.get(prefix + "_first");
int paramNo = 0;
stmt.bind(++paramNo, runId);
stmt.bind(++paramNo, depVarsList.get(0).getBenchmarkPrefix());
stmt.step();
stmt.reset();
SQLiteStatement sIndex = db.prepare("SELECT last_insert_rowid() FROM " + prefix + "DependentVars");
sIndex.step();
String dvId = sIndex.columnString(0);
sIndex.dispose();
for (int j = 0; j < depVarsList.size(); ++j)
{
DependentVariables depVars = depVarsList.get(j);
for (int i = 0; i < depVars.getValues().size(); ++i)
{
stmt = dvStmnts.get(prefix + "_second");
paramNo = 0;
stmt.bind(++paramNo, dvId);
stmt.bind(++paramNo, depVars.getValues().get(i).getOperation());
stmt.bind(++paramNo, depVars.getValues().get(i).getOperationMetric().getValue());
stmt.bind(++paramNo, depVars.getValues().get(i).getValue());
if (depVars.getValues().get(i) instanceof DependentVariablesValueSingle)
{
//System.out.println(depVars.getValues().get(i));
stmt.bind(++paramNo, ((DependentVariablesValueSingle) depVars.getValues().get(i)).getTimestamp());
stmt.bind(++paramNo, Type.SINGLE_VALUE_VALUE);
} else if (depVars.getValues().get(i) instanceof DependentVariablesValueComposite)
{
//System.out.println(depVars.getValues().get(i));
stmt.bind(++paramNo, "");
stmt.bind(++paramNo, ((DependentVariablesValueComposite) depVars.getValues().get(i)).getType().getValue());
}
stmt.step();
stmt.reset();
}
LOGGER.trace("Finished Saving Dependent Vars %s", depVars);
}
}
示例9: main
import com.almworks.sqlite4java.SQLiteStatement; //导入方法依赖的package包/类
public static void main(String[] args) throws SQLiteException {
SQLiteConnection db = new SQLiteConnection(new File("testdb"));
db.open(true);
SQLiteStatement st = db.prepare("CREATE TABLE IF NOT EXISTS servers" +
"(" +
"id INTEGER PRIMARY KEY AUTOINCREMENT," +
"ipaddress varchar(255)," +
"queryport int" +
")");
try {
st.step();
} finally {
st.dispose();
}
//SQLiteStatement st2 = db.prepare("SHOW TABLES LIKE %servers%");
SQLiteStatement st2 = db.prepare("SELECT name FROM sqlite_master WHERE type = \"table\"");
String tables = "";
try {
//st2.bind(1, tables);
st2.step();
tables = st2.columnString(0);
} finally {
st2.dispose();
}
System.out.println(tables);
st2 = db.prepare("INSERT INTO servers (ipaddress, queryport) VALUES ('123.456.789.123', 27015)");
try {
st2.step();
} finally {
st2.dispose();
}
st2 = db.prepare("SELECT COUNT(*) FROM servers");
String count = "";
try {
st2.step();
count = st2.columnString(0);
} finally {
st2.dispose();
}
System.out.println(count);
db.dispose();
}