ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Igor Sapego (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-9342) The same SQL request with multiple statements produces different result
Date Tue, 21 Aug 2018 13:05:00 GMT
Igor Sapego created IGNITE-9342:
-----------------------------------

             Summary: The same SQL request with multiple statements produces different result
                 Key: IGNITE-9342
                 URL: https://issues.apache.org/jira/browse/IGNITE-9342
             Project: Ignite
          Issue Type: Bug
          Components: jdbc, odbc, sql
    Affects Versions: 2.6
            Reporter: Igor Sapego


The bug affects ODBC and JDBC. Simply speaking, the following code:
{code:java}
public static void main(String[] args) throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();

    cfg.setLocalHost("127.0.0.1");

    try (Ignite ignite = Ignition.start(cfg)) {

        try (Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/"))
{

            // Populate City table with PreparedStatement.
            try (PreparedStatement stmt = conn.prepareStatement("SELECT 1; SELECT 2")) {
                System.out.println("First run:");

                executeAndFetch(stmt);

                System.out.println();
                System.out.println("Second run:");

                executeAndFetch(stmt);
            }
        }
    }
}

static void executeAndFetch(PreparedStatement stmt) throws SQLException {
    ResultSet set = stmt.executeQuery();

    System.out.println(">>>  First result set:");

    while (set.next())
        System.out.println(">>>    " + set.getInt(1));

    System.out.println(">>>  Next result set:");

    boolean nextRsPresent = stmt.getMoreResults();

    if (!nextRsPresent)
        System.out.println(">>>    Is not present");
    else
    {
        set = stmt.getResultSet();

        while (set.next())
            System.out.println(">>>    " + set.getInt(1));
    }
}
{code}
Produces the following output:
{noformat}
First run:
>>>  First result set:
>>>    1
>>>  Next result set:
>>>    2

Second run:
>>>  First result set:
>>>    1
>>>  Next result set:
>>>    Is not present{noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message