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


Java SQLiteStatement.columnString方法代码示例

本文整理汇总了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;
}
 
开发者ID:rrodrigoa,项目名称:SmartStocks,代码行数:22,代码来源:Controller.java

示例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();
		}
	}
}
 
开发者ID:houdejun214,项目名称:lakeside-java,代码行数:19,代码来源:SqliteDB.java

示例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();
		}
	}
}
 
开发者ID:houdejun214,项目名称:lakeside-java,代码行数:19,代码来源:SqliteSafeDBWithPool.java

示例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;
}
 
开发者ID:tranek,项目名称:ChivalryServerBrowser,代码行数:45,代码来源:MasterServerQueryFav.java

示例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;
}
 
开发者ID:tranek,项目名称:ChivalryServerBrowser,代码行数:48,代码来源:MainWindow.java

示例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;
}
 
开发者ID:tranek,项目名称:ChivalryServerBrowser,代码行数:45,代码来源:MasterServerQueryHistory.java

示例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);
	}

}
 
开发者ID:StoragePerformanceAnalyzer,项目名称:SPA,代码行数:57,代码来源:SQLiteHelper.java

示例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);
	}

}
 
开发者ID:StoragePerformanceAnalyzer,项目名称:SPA,代码行数:56,代码来源:SQLiteHelper.java

示例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();
	}
 
开发者ID:tranek,项目名称:ChivalryServerBrowser,代码行数:52,代码来源:DatabaseTest.java


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