trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [1/3] incubator-trafodion git commit: TRAFODION-2788 - jdbc does not implement ClinetInfo related api
Date Fri, 08 Dec 2017 23:40:22 GMT
Repository: incubator-trafodion
Updated Branches:
  refs/heads/master 14851367b -> 0282c8552


TRAFODION-2788 - jdbc does not implement ClinetInfo related api


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

Branch: refs/heads/master
Commit: 3ac544c615e9bb6545eab06dfadfaff565ba1d70
Parents: 371cb71
Author: gpj1987 <gpj1987@gmail.com>
Authored: Mon Oct 30 16:51:07 2017 +0800
Committer: gpj1987 <gpj1987@gmail.com>
Committed: Mon Oct 30 16:51:07 2017 +0800

----------------------------------------------------------------------
 .../trafodion/jdbc/t4/InterfaceConnection.java  | 18 +++++
 .../org/trafodion/jdbc/t4/T4Properties.java     | 14 ++++
 .../org/trafodion/jdbc/t4/TrafT4Connection.java | 20 ++---
 .../org/trafodion/jdbc_test/TestClientInfo.java | 78 ++++++++++++++++++++
 4 files changed, 118 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3ac544c6/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
index b3c7f03..46bed22 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceConnection.java
@@ -37,10 +37,12 @@ import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CodingErrorAction;
 import java.nio.charset.UnsupportedCharsetException;
 import java.sql.Connection;
+import java.sql.SQLClientInfoException;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
 import java.util.Hashtable;
 import java.util.Locale;
+import java.util.Properties;
 import java.util.logging.Handler;
 import java.util.logging.Level;
 
@@ -1417,4 +1419,20 @@ class InterfaceConnection {
 	public String getApplicationName() {
 		return this.t4props_.getApplicationName();
 	}
+	
+	void setClientInfoProperties(Properties prop) {
+		this.t4props_.setClientInfoProperties(prop);
+	}
+
+	Properties getClientInfoProperties() {
+		return this.t4props_.getClientInfoProperties();
+	}
+
+	public void setClientInfo(String name, String value) throws SQLClientInfoException {
+		this.t4props_.getClientInfoProperties().setProperty(name, value);
+	}
+
+	String getClientInfo(String name) {
+		return this.t4props_.getClientInfoProperties().getProperty(name);
+	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3ac544c6/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java
index 917cf45..8530b8c 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/T4Properties.java
@@ -140,6 +140,10 @@ public class T4Properties {
 
 	// Log file handler for this connection.
 	FileHandler t4LogFileHandler_;
+	
+	//clientInfoProperties
+	private Properties clientInfoProp;
+	
 
 	private boolean SPJEnv_ = false;
 	private boolean keepRawFetchBuffer_ = false;
@@ -292,6 +296,7 @@ public class T4Properties {
 		sqlExceptionMessage_ = null;
 		inprops_ = props;
 		setProperties();
+		clientInfoProp = new Properties();
 	}
 
 	// ---------------------------------------------------------------
@@ -2508,4 +2513,13 @@ public class T4Properties {
 
 	// -------------------------------------------------------------------------
 
+    void setClientInfoProperties(Properties prop) {
+        this.clientInfoProp = prop;
+    }
+
+    Properties getClientInfoProperties() {
+        return this.clientInfoProp;
+    }
+	
+	
 }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3ac544c6/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..fbfdb4f 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
@@ -1881,26 +1881,22 @@ public class TrafT4Connection extends PreparedStatementManager implements
java.s
 		return false;
 	}
 
-	public void setClientInfo(String name, String value)
-			throws SQLClientInfoException {
-		// TODO Auto-generated method stub
-		
+	public void setClientInfo(String name, String value) throws SQLClientInfoException {
+		ic_.setClientInfo(name, value);
 	}
 
-	public void setClientInfo(Properties properties)
-			throws SQLClientInfoException {
-		// TODO Auto-generated method stub
-		
+	public void setClientInfo(Properties properties) throws SQLClientInfoException {
+		ic_.setClientInfoProperties( properties);
 	}
 
 	public String getClientInfo(String name) throws SQLException {
-		// TODO Auto-generated method stub
-		return null;
+		validateConnection();
+		return ic_.getClientInfoProperties().getProperty(name);
 	}
 
 	public Properties getClientInfo() throws SQLException {
-		// TODO Auto-generated method stub
-		return null;
+		validateConnection();
+		return ic_.getClientInfoProperties();
 	}
 
 	public Array createArrayOf(String typeName, Object[] elements)

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3ac544c6/dcs/src/test/jdbc_test/src/test/java/org/trafodion/jdbc_test/TestClientInfo.java
----------------------------------------------------------------------
diff --git a/dcs/src/test/jdbc_test/src/test/java/org/trafodion/jdbc_test/TestClientInfo.java
b/dcs/src/test/jdbc_test/src/test/java/org/trafodion/jdbc_test/TestClientInfo.java
new file mode 100644
index 0000000..1971b0f
--- /dev/null
+++ b/dcs/src/test/jdbc_test/src/test/java/org/trafodion/jdbc_test/TestClientInfo.java
@@ -0,0 +1,78 @@
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.junit.Test;
+
+public class TestClientInfo {
+    @Test
+    public void testGetClientInfoProperties() {
+        Connection conn = null;
+        try {
+            System.out.println("Connecting to database...");
+            conn = Utils.getUserConnection();
+            Properties clientInfo = conn.getClientInfo();
+            assertTrue("this is not set clientInfo Properties", clientInfo.equals(new Properties()));
+            System.out.println(clientInfo);
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+
+    @Test
+    public void testSetAndGetClientInfoProperties() {
+        Connection conn = null;
+        try {
+            System.out.println("Connecting to database...");
+            conn = Utils.getUserConnection();
+            Properties prop = new Properties();
+            prop.setProperty("user1", "user1");
+            prop.setProperty("user2", "user2");
+            conn.setClientInfo(prop);
+            Properties prop1 = conn.getClientInfo();
+            assertTrue("this is set and get  ClientInfoProperties", prop1.equals(prop));
+            System.out.println(prop1.equals(prop));
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+    @Test
+    public void testSetAndGetClientInfoByName() {
+        Connection conn = null;
+        try {
+            System.out.println("Connecting to database...");
+            conn = Utils.getUserConnection();
+            conn.setClientInfo("user1", "user1");
+            String user1 = conn.getClientInfo("user1");
+            System.out.println(user1);
+            assertTrue("this is set clientInfo by Name ", user1.equals("user1"));
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+    @Test
+    public void testSetAndGetClientInfoByName1() {
+        Connection conn = null;
+        try {
+            System.out.println("Connecting to database...");
+            conn = Utils.getUserConnection();
+            Properties prop = new Properties();
+            prop.setProperty("user2", "user2");
+            conn.setClientInfo(prop);
+            conn.setClientInfo("user1", "user1");
+            String user1 = conn.getClientInfo("user1");
+            String user2 = conn.getClientInfo("user2");
+            String user3 = conn.getClientInfo("user3");
+            System.out.println(user1);
+            System.out.println(user2);
+            System.out.println(user3);
+           // assertTrue("this is get clientInfo by Name", user1.equals("user1"));
+           // assertTrue("this is get clientInfo by Name", user2.equals("user2"));
+            assertTrue("this is get clientInfo by Name", user3==(null));
+        } catch (SQLException e) {
+            e.printStackTrace();
+        }
+    }
+}


Mime
View raw message