A database client allows you to obtain an active connection to a relational database.
A database client has a type parameter which should correspond to a class that is annotated with
To get an instance of a
DatabaseClient you do:
DatabaseClient client = ClientBuilder.getDatabaseClient(DatabaseClass.class);
In addition the serverless function from which the client is used needs to be annotated with
@UsesRelationalDatabase(DatabaseClass.class), to handle cloud permissions.
In this example
DatabaseClass would be replaced with your class that you have annotated with
Connection getConnection()- Returns an active connection to the database, with no active database selected.
Connection getConnection(String databaseName, boolean createIfNotExist)- Returns an active connection to the database with an active database selected. Option for creating this database if it does not exist.
dataModel- The class annotated with
@RelationalDatabasethat this function will access.
stages- The stages which this function has access to the relational database