用户、管理员
必须先初始化 AppCenter 客户端,然后才能使用 AppCenter Java SDK。
- 使用以下方法之一初始化客户端:
方法 代码示例 注意事项 try-with-resources try (AppcenterClient client = new DefaultAppcenterClient()) { // your codes that utilize the client }
Teradata 建议使用 try-with-resources 语句来确保每个资源在语句结束后关闭。 try-catch-finally AppcenterClient client = null; try { client = new DefaultAppcenterClient(); // your codes that utilize the client } catch (...) { ... } finally { client.close(); }
务必在 'finally' 块中调用 client.close(),以确保资源已正确关闭。 使用 AppContext 初始化 AppCenter 客户端 AppContext appContext = new AppContext() .appcenterBaseUrl(“https://appcenter.example.com”) .system(“aster-system”) .build(); try (AppcenterClient client = new DefaultAppCenterClient(appContext)) { // your codes that utilize the client }
使用首选设置构建 AppContext,然后使用已构建的 AppContext 初始化 AppCenter 客户端。 可以使用以下变量来构造 AppContext:变量 说明 示例 system 数据源名称 "****-system" database 数据库名称 "appcenter-examples" user 用于访问数据源的用户名 "user" password 用于访问数据源的密码 "pass" catalog Presto 系统的目录 "hive" schema Presto 系统的模式 "default" jobConfig 作业参数 {"param1":"value", "param2":"value"} appConfig 应用程序参数定义 {"param1":{"type":"text","default_value":"default","required":false}} resultConfig 可视化配置 {"query1":{"name":"query1","type":"sankey","format":"npath"}} appCenterBaseUrl AppCenter 实例基本 URL "https://appcenter.example.com"