ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [12/33] ignite git commit: ignite-5685 JDBC prepared statement shouldn't clear parameters after execution
Date Wed, 05 Jul 2017 11:23:54 GMT
ignite-5685 JDBC prepared statement shouldn't clear parameters after execution


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2e7adbfb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2e7adbfb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2e7adbfb

Branch: refs/heads/ignite-2.1.2-exchange
Commit: 2e7adbfbbab62f3b98e0409d2f4ceabad89b4120
Parents: b69f53e
Author: agura <agura@gridgain.com>
Authored: Tue Jul 4 16:56:40 2017 +0300
Committer: agura <agura@gridgain.com>
Committed: Tue Jul 4 17:47:46 2017 +0300

----------------------------------------------------------------------
 .../jdbc2/JdbcPreparedStatementSelfTest.java    | 35 ++++++++++++++++++++
 .../jdbc/JdbcPreparedStatementSelfTest.java     | 35 ++++++++++++++++++++
 .../thin/JdbcThinPreparedStatementSelfTest.java | 35 ++++++++++++++++++++
 .../internal/jdbc/JdbcPreparedStatement.java    |  6 +---
 .../jdbc/thin/JdbcThinPreparedStatement.java    |  2 --
 .../internal/jdbc2/JdbcPreparedStatement.java   | 12 ++-----
 6 files changed, 108 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/2e7adbfb/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
index e2939e6..7df0e02 100644
--- a/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatementSelfTest.java
@@ -159,6 +159,41 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
+    public void testRepeatableUsage() throws Exception {
+        stmt = conn.prepareStatement("select * from TestObject where id = ?");
+
+        stmt.setInt(1, 1);
+
+        ResultSet rs = stmt.executeQuery();
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0)
+                assertEquals(1, rs.getInt(1));
+
+            cnt++;
+        }
+
+        assertEquals(1, cnt);
+
+        cnt = 0;
+
+        rs = stmt.executeQuery();
+
+        while (rs.next()) {
+            if (cnt == 0)
+                assertEquals(1, rs.getInt(1));
+
+            cnt++;
+        }
+
+        assertEquals(1, cnt);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testBoolean() throws Exception {
         stmt = conn.prepareStatement("select * from TestObject where boolVal is not distinct
from ?");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e7adbfb/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java
index 0dfa0fd..384036a 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/JdbcPreparedStatementSelfTest.java
@@ -156,6 +156,41 @@ public class JdbcPreparedStatementSelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
+    public void testRepeatableUsage() throws Exception {
+        stmt = conn.prepareStatement("select * from TestObject where id = ?");
+
+        stmt.setInt(1, 1);
+
+        ResultSet rs = stmt.executeQuery();
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0)
+                assertEquals(1, rs.getInt(1));
+
+            cnt++;
+        }
+
+        assertEquals(1, cnt);
+
+        cnt = 0;
+
+        rs = stmt.executeQuery();
+
+        while (rs.next()) {
+            if (cnt == 0)
+                assertEquals(1, rs.getInt(1));
+
+            cnt++;
+        }
+
+        assertEquals(1, cnt);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testBoolean() throws Exception {
         stmt = conn.prepareStatement("select * from TestObject where boolVal is not distinct
from ?");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e7adbfb/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
index 6f18c75..841a0af 100644
--- a/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
+++ b/modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementSelfTest.java
@@ -164,6 +164,41 @@ public class JdbcThinPreparedStatementSelfTest extends JdbcThinAbstractSelfTest
     /**
      * @throws Exception If failed.
      */
+    public void testRepeatableUsage() throws Exception {
+        stmt = conn.prepareStatement(SQL_PART + " where id = ?");
+
+        stmt.setInt(1, 1);
+
+        ResultSet rs = stmt.executeQuery();
+
+        int cnt = 0;
+
+        while (rs.next()) {
+            if (cnt == 0)
+                assertEquals(1, rs.getInt(1));
+
+            cnt++;
+        }
+
+        assertEquals(1, cnt);
+
+        cnt = 0;
+
+        rs = stmt.executeQuery();
+
+        while (rs.next()) {
+            if (cnt == 0)
+                assertEquals(1, rs.getInt(1));
+
+            cnt++;
+        }
+
+        assertEquals(1, cnt);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testQueryExecuteException() throws Exception {
         stmt = conn.prepareStatement(SQL_PART + " where boolVal is not distinct from ?");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e7adbfb/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
index 7e5358b..93cda1e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/JdbcPreparedStatement.java
@@ -69,11 +69,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
 
     /** {@inheritDoc} */
     @Override public ResultSet executeQuery() throws SQLException {
-        ResultSet rs = executeQuery(sql);
-
-        args = null;
-
-        return rs;
+        return executeQuery(sql);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e7adbfb/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
index 49a78b6..0c78a13 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc/thin/JdbcThinPreparedStatement.java
@@ -219,8 +219,6 @@ public class JdbcThinPreparedStatement extends JdbcThinStatement implements
Prep
      */
     private void executeWithArguments() throws SQLException {
         execute0(sql, args);
-
-        args = null;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/2e7adbfb/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
index 1a66ced..16030f7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/jdbc2/JdbcPreparedStatement.java
@@ -73,22 +73,14 @@ public class JdbcPreparedStatement extends JdbcStatement implements PreparedStat
     @Override public ResultSet executeQuery() throws SQLException {
         ensureNotClosed();
 
-        ResultSet rs = executeQuery(sql);
-
-        args = null;
-
-        return rs;
+        return executeQuery(sql);
     }
 
     /** {@inheritDoc} */
     @Override public int executeUpdate() throws SQLException {
         ensureNotClosed();
 
-        int res = executeUpdate(sql);
-
-        args = null;
-
-        return res;
+        return executeUpdate(sql);
     }
 
     /** {@inheritDoc} */


Mime
View raw message