trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [1/2] incubator-trafodion git commit: Statement for metadata should be closed with connection
Date Tue, 31 Oct 2017 18:15:52 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master f42450f75 -> e0ee8e430


Statement for metadata should be closed with connection

Statement for metadata should be closed with connection


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/7de9b968
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/7de9b968
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/7de9b968

Branch: refs/heads/master
Commit: 7de9b9684864ee23bed5118f5e02a4b03b9bb43a
Parents: acadd04
Author: gabriel <gabriel.wang.sh@gmail.com>
Authored: Sat Oct 28 19:53:03 2017 +0800
Committer: gabriel <gabriel.wang.sh@gmail.com>
Committed: Sat Oct 28 20:10:13 2017 +0800

----------------------------------------------------------------------
 .../java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java    | 10 ++++++++--
 .../main/java/org/trafodion/jdbc/t4/TrafT4Connection.java |  8 +++++---
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7de9b968/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
index a35b8e3..ffd9ae3 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4DatabaseMetaData.java
@@ -27,6 +27,8 @@ import java.sql.ResultSet;
 import java.sql.RowIdLifetime;
 import java.sql.SQLException;
 import java.sql.Types;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 
@@ -69,6 +71,7 @@ import java.util.logging.LogRecord;
  */
 public class T4DatabaseMetaData extends TrafT4Handle implements java.sql.DatabaseMetaData
{
 
+	private Map<String, TrafT4Statement> stmtMap_ = new ConcurrentHashMap<String, TrafT4Statement>(16);
 	// ----------------------------------------------------------------------
 	// First, a variety of minor information about the target database.
 
@@ -5636,7 +5639,7 @@ public class T4DatabaseMetaData extends TrafT4Handle implements java.sql.Databas
 			hashcode = -hashcode;
 
 		}
-		String stmtLabel = "STMT_CATALOG_" + hashcode + 1000;
+		String stmtLabel = "STMT_CA_" + catalogAPI  + hashcode + 1000;
 		if (stmtLabel.length() > 17) {
 			stmtLabel = stmtLabel.substring(0, 17);
 
@@ -5764,7 +5767,10 @@ public class T4DatabaseMetaData extends TrafT4Handle implements java.sql.Databas
 			}
 
 			TrafT4Desc[] outputDesc = InterfaceStatement.NewDescArray(gcr_.m_p3);
-
+			if (!this.stmtMap_.containsKey(stmtLabel) || this.stmtMap_.get(stmtLabel).isClosed())
{
+				//Initialize a statement for MD queries, and this stmt will be removed while closing
connection		 +				// Initialize a statement for MD queries, and this stmt will be
+				this.stmtMap_.put(stmtLabel, new TrafT4Statement(this.connection_, stmtLabel));
+			}
 			resultSet_ = new TrafT4ResultSet(this, outputDesc, gcr_.m_p2, true);
 			resultSet_.proxySyntax_ = gcr_.proxySyntax;
 			break;

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7de9b968/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
index 2a8e381..178f034 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4Connection.java
@@ -68,6 +68,7 @@ import javax.sql.PooledConnection;
  */
 public class TrafT4Connection extends PreparedStatementManager implements java.sql.Connection
{
 
+	private T4DatabaseMetaData metaData_;
 	/**
 	 * Validates the connection by clearing warnings and verifying that the
 	 * Connection is still open.
@@ -306,7 +307,7 @@ public class TrafT4Connection extends PreparedStatementManager implements
java.s
 
 		validateConnection();
 
-		return new T4DatabaseMetaData(this);
+		return this.metaData_;
 	}
 
 	public int getTransactionIsolation() throws SQLException {
@@ -1644,6 +1645,7 @@ public class TrafT4Connection extends PreparedStatementManager implements
java.s
 		if (props_.getSPJEnv()) {
 			ic_.enableProxySyntax(this);
 		}
+		this.metaData_ = new T4DatabaseMetaData(this);
 	}
 	
 	private ArrayList<String> createAddressList(T4Properties t4props) {
@@ -1859,11 +1861,11 @@ public class TrafT4Connection extends PreparedStatementManager implements
java.s
 	}
 
 	public Clob createClob() throws SQLException {
-        return new TrafT4Clob(this, null, null);
+		return new TrafT4Clob(this, null, null);
 	}
 
 	public Blob createBlob() throws SQLException {
-        return new TrafT4Blob(this, null, null);
+		return new TrafT4Blob(this, null, null);
 	}
 
 	public NClob createNClob() throws SQLException {


Mime
View raw message