jdbc:hive2://{endpoint}:10009/?spark.engine={DataEngineName};spark.resourcegroup={ResourceGroupName};secretkey={SecretKey};secretid={SecretId};region={Region};kyuubi.engine.type=SPARK_SQL;kyuubi.engine.share.level=ENGINE
Class.forName("org.apache.hive.jdbc.HiveDriver");
jdbc:hive2://{endpoint}:10009/?spark.engine={DataEngineName};spark.resourcegroup={ResourceGroupName};secretkey={SecretKey};secretid={SecretId};region={Region};kyuubi.engine.type=SPARK_SQL;kyuubi.engine.share.level=ENGINEProperties properties = new Properties();properties.setProperty("user", {AppId});Connection cnct = DriverManager.getConnection(url, properties);
Parameter | Required | Description |
spark.engine | Yes | The name of the Standard Spark Engine |
spark.resourcegroup | No | The name of the Standard Spark Engine resource group. If it is not specified, temporary resources will be created. |
secretkey | Yes | The SecretKey from Tencent Cloud API Key Management |
secretid | Yes | The SecretId from Tencent Cloud API Key Management |
region | Yes | The region. Currently, DLC services support the following: ap-nanjing, ap-beijing, ap-beijing-fsi, ap-guangzhou,ap-shanghai, ap-chengdu,ap-chongqing, na-siliconvalley, ap-singapore, ap-hongkong, na-ashburn, eu-frankfurt, ap-shanghai-fsi |
kyuubi.engine.type | Yes | Must be set to: SparkSQLTask |
kyuubi.engine.share.level | Yes | Must be set to: ENGINE |
user | Yes | The user's APPID |
import org.apache.hive.jdbc.HiveStatement;import java.sql.*;import java.util.Properties;public class TestStandardSpark {public static void main(String[] args) throws SQLException {try {Class.forName("org.apache.hive.jdbc.HiveDriver");} catch (ClassNotFoundException e) {e.printStackTrace();return;}String url = "jdbc:hive2://{endpoint}:10009/?spark.engine={DataEngineName};spark.resourcegroup={ResourceGroupName};secretkey={SecretKey};secretid={SecretId};region={Region};kyuubi.engine.type=SPARK_SQL;kyuubi.engine.share.level=ENGINE";Properties properties = new Properties();properties.setProperty("user", {AppId});Connection connection = DriverManager.getConnection(url, properties);HiveStatement statement = (HiveStatement) connection.createStatement();String sql = "SELECT * FROM dlc_test LIMIT 100";statement.execute(sql);ResultSet rs = statement.getResultSet();while (rs.next()) {System.out.println(rs.getInt(1) + ":" + rs.getString(2));}rs.close();statement.close();connection.close();}}
Was this page helpful?