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


Java ResultSet.isClosed方法代码示例

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


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

示例1: isClosed

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public boolean isClosed() throws SQLException {
    if (this.results != null) {
        for (LabeledResultSet r : this.results) {
            ResultSet s = r.getResultSet();
            if (s != null) {
                try {
                    if (!s.isClosed()) {
                        return false;
                    }
                }
                catch (SQLException e) {
                    throw new RuntimeException(e.getMessage(), e);
                }
            }
        }
    }
    return true;
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:20,代码来源:MultiShardResultSet.java

示例2: closeInvoked

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public void closeInvoked() {
    //should we cache it
    boolean shouldClose = true;
    if (cacheSize.get() < maxCacheSize) {
        //cache a proxy so that we don't reuse the facade
        CachedStatement proxy = new CachedStatement(getDelegate(),getSql());
        proxy.setCacheKey(getCacheKey());
        try {
            // clear Resultset
            ResultSet result = getDelegate().getResultSet();
            if (result != null && !result.isClosed()) {
                result.close();
            }
            //create a new facade
            Object actualProxy = getConstructor().newInstance(new Object[] { proxy });
            proxy.setActualProxy(actualProxy);
            proxy.setConnection(getConnection());
            proxy.setConstructor(getConstructor());
            if (cacheStatement(proxy)) {
                proxy.cached = true;
                shouldClose = false;
            }
        } catch (Exception x) {
            removeStatement(proxy);
        }
    }
    if (shouldClose) {
        super.closeInvoked();
    }
    closed = true;
    delegate = null;

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:35,代码来源:StatementCache.java

示例3: closeConnection

import java.sql.ResultSet; //导入方法依赖的package包/类
public void closeConnection(Connection con, PreparedStatement ps, ResultSet rs) throws SQLException {
    if (con.isClosed() == false) {
        con.close();
    }
    if (ps.isClosed() == false) {
        ps.close();
    }
    if (rs.isClosed() == false) {
        rs.close();
    }
}
 
开发者ID:seyidkanan,项目名称:my-diploma-work,代码行数:12,代码来源:ConnectionDB.java

示例4: closeResultSet

import java.sql.ResultSet; //导入方法依赖的package包/类
public static void closeResultSet(ResultSet rs){
    try{
        if(rs != null && !rs.isClosed()){
            rs.close();
        }
    }catch(Exception e){
        //
    }
}
 
开发者ID:madHEYsia,项目名称:ClassroomFlipkart,代码行数:10,代码来源:DBUtils.java

示例5: hasLevel30Character

import java.sql.ResultSet; //导入方法依赖的package包/类
public boolean hasLevel30Character() {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        ps = DatabaseConnection.getConnection().prepareStatement("SELECT `level` FROM `characters` WHERE accountid = ?");
        ps.setInt(1, getPlayer().getAccountID());
        rs = ps.executeQuery();
        while (rs.next()) {
            if (rs.getInt("level") >= 30) {
                return true;
            }
        }
    } catch (SQLException sqle) {
        sqle.printStackTrace();
    } finally {
        try {
            if (ps != null && !ps.isClosed()) {
                ps.close();
            }
            if (rs != null && !rs.isClosed()) {
                rs.close();
            }
        } catch (SQLException ex) {
        }
    }
    return false;
}
 
开发者ID:NovaStory,项目名称:AeroStory,代码行数:28,代码来源:PortalPlayerInteraction.java

示例6: executeInternal

import java.sql.ResultSet; //导入方法依赖的package包/类
/**
 * Executes a prepared statement.
 *
 * @param signature Parsed statement
 * @param isUpdate if the execute is for an update
 *
 * @return as specified by {@link java.sql.Statement#execute(String)}
 * @throws java.sql.SQLException if a database error occurs
 */
protected boolean executeInternal(Meta.Signature signature, boolean isUpdate)
    throws SQLException {
  ResultSet resultSet = executeQueryInternal(signature, isUpdate);
  // user may have cancelled the query
  if (resultSet.isClosed()) {
    return false;
  }
  return true;
}
 
开发者ID:apache,项目名称:calcite-avatica,代码行数:19,代码来源:AvaticaStatement.java

示例7: fetchQuestion

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public QuestionInterface fetchQuestion(long chatID) {
	Connection connection;
	try {
		// lade numberaskedquestions und gameid von dem letzten Spiel mit der chatId
		// lade questiongame von dem Spiel
		// gehe bis zu dem aktuellen numberaskedquestions-Wert und lade die
		// entsprechende Frage
		// inkrementiere numberaskedquestions
		// gib die Frage zurück
		connection = DriverManager.getConnection("jdbc:sqlite:" + QuizController.DB_PATH);
		Statement statement = connection.createStatement();
		int dbGameId, askedQuestions;
		ResultSet gameSet = statement.executeQuery("SELECT gameid, numberaskedquestions FROM game "
				+ "WHERE chatid=" + chatID + " AND gameid=(SELECT MAX(gameid) FROM game)");
		if (gameSet.next()) {
			dbGameId = gameSet.getInt("gameid");
			askedQuestions = gameSet.getInt("numberaskedquestions");

		} else {
			throw new RuntimeException("Es existiert kein Spiel mit der chatId: " + chatID);
		}

		ResultSet questionGameSet = statement
				.executeQuery("SELECT questionid,gameid FROM questiongame WHERE gameid=" + dbGameId);
		int i = 0;
		while (questionGameSet.next() && i < askedQuestions) {
			i++;
		}
		if (!questionGameSet.isClosed()) {
			int questionId = questionGameSet.getInt("questionid");
			Question question = new Question(questionId);
			statement.execute(
					"UPDATE game SET numberaskedquestions=" + (askedQuestions + 1) + " WHERE gameid=" + dbGameId);
			connection.close();
			return question;
		}
	} catch (SQLException e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:argo2445,项目名称:QBot,代码行数:43,代码来源:QuizController.java

示例8: processRow

import java.sql.ResultSet; //导入方法依赖的package包/类
@Override
public void processRow(ResultSet rs) throws SQLException {
    if (isConnected()) {

        if (rs.isClosed()) {
            throw new IllegalStateException(
                    "ResultSet already closed. We should not have got here. THIS IS A BUG!");
        }

        Fact f = PGFact.from(rs);
        final UUID factId = f.id();

        if (postQueryMatcher.test(f)) {
            try {
                subscription.notifyElement(f);
                log.trace("{} onNext called with id={}", request, factId);
            } catch (Throwable e) {
                // debug level, because it happens regularly on
                // disconnecting clients.
                // TODO add sid
                log.debug("{} exception from subscription: {}", request, e.getMessage());

                try {
                    subscription.close();
                } catch (Exception e1) {
                    // TODO add sid
                    log.warn("{} exception while closing subscription: {}", request, e1
                            .getMessage());
                }

                // close result set in order to release DB resources as
                // early as possible
                rs.close();

                throw e;

            }
        } else {
            // TODO add sid
            log.trace("{} filtered id={}", request, factId);
        }
        serial.set(rs.getLong(PGConstants.COLUMN_SER));
    }
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:45,代码来源:PGFactStream.java

示例9: validateResultSet

import java.sql.ResultSet; //导入方法依赖的package包/类
private MultiShardException validateResultSet(ResultSet r,
        ShardLocation loc) throws SQLException {
    if (r.isClosed()) {
        // ResultSet is already closed. Hence adding an exception in its place.
        return new MultiShardException(loc, new MultiShardResultSetClosedException(
                String.format("The result set for '%1$s' was closed and could not be added.", loc.getDatabase())));
    }
    ResultSetMetaData m = r.getMetaData();
    if (m == null || m.getColumnCount() == 0) {
        // ResultSet does not have proper metadata to read.
        return new MultiShardException(loc, new MultiShardResultSetInternalException(
                String.format("The result set for '%1$s' does not have proper metadata to read and could not be added.", loc.getDatabase())));
    }
    if (this.schemaComparisonTemplate == null) {
        this.schemaComparisonTemplate = r.getMetaData();
        return null;
    }
    for (int i = 1; i <= m.getColumnCount(); i++) {
        // Get the designated column's name.
        String expectedName = this.schemaComparisonTemplate.getColumnName(i);
        String actualName = m.getColumnName(i);
        if (!Objects.equals(expectedName, actualName)) {
            return new MultiShardException(loc, new MultiShardSchemaMismatchException(loc,
                    String.format("Expected schema column name %1$s, but encountered schema column name %2$s.", expectedName, actualName)));
        }

        // Retrieves the designated column's SQL type.
        if (!Objects.equals(this.schemaComparisonTemplate.getColumnType(i), m.getColumnType(i))) {
            return new MultiShardException(loc,
                    new MultiShardSchemaMismatchException(loc,
                            String.format("Mismatched SQL type values for column %1$s. Expected: %2$s. Actual: %3$s", actualName,
                                    this.schemaComparisonTemplate.getColumnTypeName(i), m.getColumnTypeName(i))));
        }

        // Get the designated column's specified column size.
        int expectedPrecision = this.schemaComparisonTemplate.getPrecision(i);
        int actualPrecision = m.getPrecision(i);
        if (!Objects.equals(expectedPrecision, actualPrecision)) {
            return new MultiShardException(loc,
                    new MultiShardSchemaMismatchException(loc,
                            String.format("Mismatched nullability values for column %1$s. Expected: %2$s. Actual: %3$s", actualName,
                                    expectedPrecision, actualPrecision)));
        }

        // Indicates the nullability of values in the designated column.
        int expectedNullableValue = this.schemaComparisonTemplate.isNullable(i);
        int actualNullableValue = m.isNullable(i);
        if (!Objects.equals(expectedNullableValue, actualNullableValue)) {
            return new MultiShardException(loc,
                    new MultiShardSchemaMismatchException(loc,
                            String.format("Mismatched nullability values for column %1$s. Expected: %2$s. Actual: %3$s", actualName,
                                    NullableValue.forValue(expectedNullableValue), NullableValue.forValue(actualNullableValue))));
        }
    }
    return null;
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:57,代码来源:MultiShardStatement.java

示例10: procurarProduto

import java.sql.ResultSet; //导入方法依赖的package包/类
public static ArrayList<Produto> procurarProduto(String nomeProduto) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM produto WHERE (produto.nome LIKE(?))";

    ArrayList<Produto> listaProdutos = null;

    Connection connection = null;

    PreparedStatement preparedStatement = null;

    ResultSet result = null;
    try {
        connection = ConnectionUtils.getConnection();

        preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setString(1, "%" + nomeProduto + "%");

        result = preparedStatement.executeQuery();

        while (result.next()) {
            if (listaProdutos == null) {
                listaProdutos = new ArrayList<>();
            }
            Produto produto = new Produto();
            produto.setId(result.getLong("id"));
            produto.setNome(result.getString("nome"));
            produto.setDescricao(result.getString("descricao"));
            produto.setValorCompra(result.getBigDecimal("vl_compra"));
            produto.setValorVenda(result.getBigDecimal("vl_venda"));
            produto.setCategoria(result.getString("categoria"));
            produto.setDtCadastro(result.getDate("dt_cadastro"));

            listaProdutos.add(produto);
        }
    } finally {
        if (result != null && !result.isClosed()) {
            result.close();
        }

        if (preparedStatement != null && !preparedStatement.isClosed()) {
            preparedStatement.close();
        }

        if (connection != null && !connection.isClosed()) {
            connection.close();
        }
    }

    return listaProdutos;
}
 
开发者ID:OgumaJr,项目名称:Entrega-Final,代码行数:51,代码来源:DaoProduto.java

示例11: obterProduto

import java.sql.ResultSet; //导入方法依赖的package包/类
public static Produto obterProduto(long id) throws SQLException, ClassNotFoundException {
    String sql = "SELECT * FROM produto WHERE (produto.id=?)";

    Connection connection = null;

    PreparedStatement preparedStatement = null;

    ResultSet result = null;
    try {
        connection = ConnectionUtils.getConnection();

        preparedStatement = connection.prepareStatement(sql);

        preparedStatement.setLong(1, id);

        result = preparedStatement.executeQuery();
        if (result.next()) {
            Produto produto = new Produto();
            produto.setId(result.getLong("id"));
            produto.setNome(result.getString("nome"));
            produto.setDescricao(result.getString("descricao"));
            produto.setValorCompra(result.getBigDecimal("vl_compra"));
            produto.setValorVenda(result.getBigDecimal("vl_venda"));
            produto.setCategoria(result.getString("categoria"));
            produto.setDtCadastro(result.getDate("dt_cadastro"));

            return produto;
        }
    } finally {
        if (result != null && !result.isClosed()) {
            result.close();
        }
        if (preparedStatement != null && !preparedStatement.isClosed()) {
            preparedStatement.close();
        }
        if (connection != null && !connection.isClosed()) {
            connection.close();
        }
    }

    return null;
}
 
开发者ID:OgumaJr,项目名称:Entrega-Final,代码行数:43,代码来源:DaoProduto.java


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