You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by "casionone (via GitHub)" <gi...@apache.org> on 2023/09/22 10:17:51 UTC
[GitHub] [linkis] casionone commented on a diff in pull request #4909: scriptis left database menu bar supports hiveserver2 to get library table fields
casionone commented on code in PR #4909:
URL: https://github.com/apache/linkis/pull/4909#discussion_r1334187275
##########
linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/org/apache/linkis/metadata/util/HiveService2Utils.java:
##########
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.util;
+
+import org.apache.commons.lang.StringUtils;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+public class HiveService2Utils {
+
+ private static final String driverName = "org.apache.hive.jdbc.HiveDriver";
+
+ private static final String defaultDb = "default";
+ private static final String defaultPassword = "123456";
+
+ static ObjectMapper jsonMapper = new ObjectMapper();
+ static SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
+
+ /** Determine whether to start hiveServer2 Query the left menu bar */
+ public static Boolean checkHiveServer2Enable() {
+ return DWSConfig.HIVE_SERVER2_ENABLE.getValue();
+ }
+
+ /** Get connection */
+ private static Connection getConn(String username, String db) throws Exception {
+ Class.forName(driverName);
+ String hiveServer2Address = DWSConfig.HIVE_SERVER2_URL.getValue();
+ String url =
+ hiveServer2Address.endsWith("/") ? hiveServer2Address + db : hiveServer2Address + "/" + db;
+ return DriverManager.getConnection(url, username, defaultPassword);
Review Comment:
need to be set defaultPassword ?
--
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: notifications-unsubscribe@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org