zhangbutao commented on code in PR #3388:
URL: https://github.com/apache/hive/pull/3388#discussion_r959260411


##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java:
##########
@@ -129,8 +129,20 @@ protected Connection getConnection() {
     throw new RuntimeException("unexpected type for connection handle");
   }
 
+  protected boolean isOpen() {
+    if (handle == null) {
+      return false;
+    }
+    try {
+      return ((Connection)handle).isClosed();
+    } catch (SQLException e) {
+      LOG.warn("Could not validate jdbc connection to"+ jdbcUrl, e);
+    }
+    return false;
+  }
+
   @Override public void close() {
-    if (isOpen) {

Review Comment:
   Yes, after this change, this boolen is dead. Will remove it.



##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/dataconnector/jdbc/AbstractJDBCConnectorProvider.java:
##########
@@ -107,8 +108,7 @@ public AbstractJDBCConnectorProvider(String dbName, 
DataConnector dataConn, Stri
 
   @Override public void open() throws ConnectException {
     try {
-      handle = DriverManager.getConnection(jdbcUrl, username, password);
-      isOpen = true;
+      handle = DriverManager.getDriver(jdbcUrl).connect(jdbcUrl, 
getConnectionProperties());

Review Comment:
   _DriverManager.getDriver().connect()_ can pass more jdbc parameters(timeout 
& retrye) when building connection.  I use 
_MySQLConnectorProvider::getConnectionProperties()_ to pass MySQL connecton 
timeout and retry..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to