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


Java DatabaseResults.first方法代码示例

本文整理汇总了Java中com.j256.ormlite.support.DatabaseResults.first方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseResults.first方法的具体用法?Java DatabaseResults.first怎么用?Java DatabaseResults.first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.j256.ormlite.support.DatabaseResults的用法示例。


在下文中一共展示了DatabaseResults.first方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: queryForFirst

import com.j256.ormlite.support.DatabaseResults; //导入方法依赖的package包/类
public T queryForFirst(DatabaseConnection paramDatabaseConnection, PreparedStmt<T> paramPreparedStmt, ObjectCache paramObjectCache)
{
  CompiledStatement localCompiledStatement = paramPreparedStmt.compile(paramDatabaseConnection, StatementBuilder.StatementType.SELECT);
  try
  {
    DatabaseResults localDatabaseResults = localCompiledStatement.runQuery(paramObjectCache);
    if (localDatabaseResults.first())
    {
      logger.debug("query-for-first of '{}' returned at least 1 result", paramPreparedStmt.getStatement());
      Object localObject2 = paramPreparedStmt.mapRow(localDatabaseResults);
      return localObject2;
    }
    logger.debug("query-for-first of '{}' returned at 0 results", paramPreparedStmt.getStatement());
    return null;
  }
  finally
  {
    localCompiledStatement.close();
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:StatementExecutor.java

示例2: queryForLong

import com.j256.ormlite.support.DatabaseResults; //导入方法依赖的package包/类
public long queryForLong(DatabaseConnection paramDatabaseConnection, PreparedStmt<T> paramPreparedStmt)
{
  CompiledStatement localCompiledStatement = paramPreparedStmt.compile(paramDatabaseConnection, StatementBuilder.StatementType.SELECT_LONG);
  try
  {
    DatabaseResults localDatabaseResults = localCompiledStatement.runQuery(null);
    if (localDatabaseResults.first())
    {
      long l = localDatabaseResults.getLong(0);
      return l;
    }
    throw new SQLException("No result found in queryForLong: " + paramPreparedStmt.getStatement());
  }
  finally
  {
    localCompiledStatement.close();
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:19,代码来源:StatementExecutor.java

示例3: queryForFirst

import com.j256.ormlite.support.DatabaseResults; //导入方法依赖的package包/类
/**
 * Return the first object that matches the {@link PreparedStmt} or null if none.
 */
public T queryForFirst(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt, ObjectCache objectCache)
		throws SQLException {
	CompiledStatement compiledStatement = preparedStmt.compile(databaseConnection, StatementType.SELECT);
	DatabaseResults results = null;
	try {
		compiledStatement.setMaxRows(1);
		results = compiledStatement.runQuery(objectCache);
		if (results.first()) {
			logger.debug("query-for-first of '{}' returned at least 1 result", preparedStmt.getStatement());
			return preparedStmt.mapRow(results);
		} else {
			logger.debug("query-for-first of '{}' returned at 0 results", preparedStmt.getStatement());
			return null;
		}
	} finally {
		IOUtils.closeThrowSqlException(results, "results");
		IOUtils.closeThrowSqlException(compiledStatement, "compiled statement");
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:23,代码来源:StatementExecutor.java

示例4: queryForLong

import com.j256.ormlite.support.DatabaseResults; //导入方法依赖的package包/类
/**
 * Return a long value from a prepared query.
 */
public long queryForLong(DatabaseConnection databaseConnection, PreparedStmt<T> preparedStmt) throws SQLException {
	CompiledStatement compiledStatement = preparedStmt.compile(databaseConnection, StatementType.SELECT_LONG);
	DatabaseResults results = null;
	try {
		results = compiledStatement.runQuery(null);
		if (results.first()) {
			return results.getLong(0);
		} else {
			throw new SQLException("No result found in queryForLong: " + preparedStmt.getStatement());
		}
	} finally {
		IOUtils.closeThrowSqlException(results, "results");
		IOUtils.closeThrowSqlException(compiledStatement, "compiled statement");
	}
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:19,代码来源:StatementExecutor.java

示例5: doCreateTestQueries

import com.j256.ormlite.support.DatabaseResults; //导入方法依赖的package包/类
private static int doCreateTestQueries(DatabaseConnection paramDatabaseConnection, DatabaseType paramDatabaseType, List<String> paramList)
{
  int i = 0;
  Iterator localIterator = paramList.iterator();
  while (localIterator.hasNext())
  {
    String str = (String)localIterator.next();
    Object localObject1 = null;
    try
    {
      CompiledStatement localCompiledStatement = paramDatabaseConnection.compileStatement(str, StatementBuilder.StatementType.SELECT, noFieldTypes);
      localObject1 = localCompiledStatement;
      DatabaseResults localDatabaseResults = localCompiledStatement.runQuery(null);
      int j = 0;
      for (boolean bool = localDatabaseResults.first(); bool; bool = localDatabaseResults.next())
        j++;
      logger.info("executing create table after-query got {} results: {}", Integer.valueOf(j), str);
    }
    catch (SQLException localSQLException)
    {
      throw SqlExceptionUtil.create("executing create table after-query failed: " + str, localSQLException);
    }
    finally
    {
      if (localObject1 != null)
        localObject1.close();
    }
    i++;
  }
  return i;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:32,代码来源:TableUtils.java

示例6: doCreateTestQueries

import com.j256.ormlite.support.DatabaseResults; //导入方法依赖的package包/类
private static int doCreateTestQueries(DatabaseConnection connection, DatabaseType databaseType,
		List<String> queriesAfter) throws SQLException {
	int stmtC = 0;
	// now execute any test queries which test the newly created table
	for (String query : queriesAfter) {
		CompiledStatement compiledStmt = null;
		try {
			compiledStmt = connection.compileStatement(query, StatementType.SELECT, noFieldTypes,
					DatabaseConnection.DEFAULT_RESULT_FLAGS, false);
			// we don't care about an object cache here
			DatabaseResults results = compiledStmt.runQuery(null);
			int rowC = 0;
			// count the results
			for (boolean isThereMore = results.first(); isThereMore; isThereMore = results.next()) {
				rowC++;
			}
			logger.info("executing create table after-query got {} results: {}", rowC, query);
		} catch (SQLException e) {
			// we do this to make sure that the statement is in the exception
			throw SqlExceptionUtil.create("executing create table after-query failed: " + query, e);
		} finally {
			// result set is closed by the statement being closed
			IOUtils.closeThrowSqlException(compiledStmt, "compiled statement");
		}
		stmtC++;
	}
	return stmtC;
}
 
开发者ID:j256,项目名称:ormlite-core,代码行数:29,代码来源:TableUtils.java


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