diff --git a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestHiveDatabaseMetaData.java b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestHiveDatabaseMetaData.java index 2e5128e1eaff..70f222e0857e 100644 --- a/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestHiveDatabaseMetaData.java +++ b/itests/hive-unit/src/test/java/org/apache/hive/jdbc/TestHiveDatabaseMetaData.java @@ -18,8 +18,6 @@ package org.apache.hive.jdbc; -import org.apache.hive.jdbc.HiveConnection; -import org.apache.hive.jdbc.Utils; import org.apache.hive.jdbc.Utils.JdbcConnectionParams; import java.util.LinkedHashMap; @@ -107,4 +105,16 @@ public void testHiveConnectionUdateServerHiveConf() { .get(Utils.JdbcConnectionParams.HIVE_CONF_PREFIX + "hive.default.nulls.last")); } + + @Test + public void testGetUserName() throws SQLException { + HiveConnection hiveConnection = new HiveConnection("jdbc:hive2:///;user=foo", new Properties()); + hiveDatabaseMetaData = new HiveDatabaseMetaData(hiveConnection, null, null); + assertEquals("foo", hiveDatabaseMetaData.getUserName()); + } + + @Test + public void testGetURL() { + assertEquals(connection.getConnectedUrl(), hiveDatabaseMetaData.getURL()); + } } \ No newline at end of file diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java index 2850ccdddde0..054400c20243 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveConnection.java @@ -1307,7 +1307,7 @@ public void updateServerHiveConf(Map serverHiveConf, JdbcConnect /** * @return username from sessConfMap */ - private String getUserName() { + String getUserName() { return getSessionValue(JdbcConnectionParams.AUTH_USER, JdbcConnectionParams.ANONYMOUS_USER); } diff --git a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java index d1cfd7eb2c56..41f9857cd5e5 100644 --- a/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java +++ b/jdbc/src/java/org/apache/hive/jdbc/HiveDatabaseMetaData.java @@ -744,12 +744,12 @@ public T getObject(int columnIndex, Class type) throws SQLException { }; } - public String getURL() throws SQLException { - throw new SQLFeatureNotSupportedException("Method not supported"); + public String getURL() { + return connection.getConnectedUrl(); } - public String getUserName() throws SQLException { - throw new SQLFeatureNotSupportedException("Method not supported"); + public String getUserName() { + return connection.getUserName(); } public ResultSet getVersionColumns(String catalog, String schema, String table)