You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "JD Zheng (JIRA)" <ji...@apache.org> on 2017/05/22 18:56:04 UTC
[jira] [Commented] (CALCITE-1801) RelRunners connection
garbage-collected prematurely
[ https://issues.apache.org/jira/browse/CALCITE-1801?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16020014#comment-16020014 ]
JD Zheng commented on CALCITE-1801:
-----------------------------------
comments from Julian:
"Maybe we use some callback to create a connection. And maybe if you are using an anonymous class it causes the connection to be garbage-collected sooner."
> RelRunners connection garbage-collected prematurely
> ---------------------------------------------------
>
> Key: CALCITE-1801
> URL: https://issues.apache.org/jira/browse/CALCITE-1801
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.13.0
> Environment: osx 10.11.6, JavaSE-1.8, junit-4.12
> Reporter: JD Zheng
> Assignee: Julian Hyde
> Priority: Minor
>
> I am using RelRunners to execute pre-built relnode tree. It works perfectly when I put the following code in the junit class:
> protected String execute(RelNode rel) {
> try (final PreparedStatement preparedStatement = RelRunners.run(rel)) {
> final ResultSet resultSet = preparedStatement.executeQuery();
> return printResult(resultSet, true);
> } catch (SQLException e) {
> throw new RuntimeException(e);
> }
> }
> However,if I put these code inside a src class, the returned resultSet is closed.
> More interestingly, if I expand the RelRunners.run() in the method like this:
> public static ResultSet execute(RelNode rel) {
> /*
> try (final PreparedStatement preparedStatement = RelRunners.run(rel)) {
> return preparedStatement.executeQuery();
> } catch (SQLException e) {
> throw new AQLExecuteErrorException(e);
> }
> */
> try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
> final RelRunner runner = connection.unwrap(RelRunner.class);
> PreparedStatement preparedStatement = runner.prepare(rel);
> return preparedStatement.executeQuery();
> } catch (SQLException e) {
> throw new AQLExecuteErrorException(e);
> }
> }
> It works again.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)