Initialize Client | Java SDK | Teradata AppCenter - 2.0 - Initializing the Teradata AppCenter Client - Teradata AppCenter

Teradata® AppCenter Java SDK User Guide

prodname
Teradata AppCenter
vrm_release
2.0
created_date
September 2020
category
Programming Reference
User Guide
featnum
B035-1118-090K

Before you can use the Teradata® AppCenter Java SDK, you must initiate the AppCenter client.

  1. Use one of the following methods to initialize the AppCenter client:
    Method Code Example Considerations
    try-with-resources
    try (AppcenterClient client = new DefaultAppcenterClient()) { // your codes that utilize the client}
    Teradata recommends the try-with-resources method to make sure that each resource is closed at the end of the statement.
    try-catch-finally
    AppcenterClient client = null; try { client = new DefaultAppcenterClient(); // your codes that utilize the client } catch (...) {   }finally { client.close(); }
    Make sure you call client.close() in the finally block to ensure resources are closed properly.
    Initialize AppCenter client with AppContext
    AppcenterContext = new AppContext()
       .appcenterBaseUrl("https://appcenter.example.com")
       .system("aster-system")
       .build()
       
    try (AppcenterClient client = new DefaultAppCenterClient(appContext)) {
       // your codes that utilize the client   
    }