Class PostgresClient

java.lang.Object
dev.lydtech.component.framework.client.database.PostgresClient

public class PostgresClient extends Object
  • Method Details

    • getInstance

      public static PostgresClient getInstance()
    • getConnection

      public static Connection getConnection() throws Exception
      Connect to Postgres with the database properties as set in System properties.
      Throws:
      Exception
    • getConnection

      public static Connection getConnection(String databaseName, String schemaName, String username, String password) throws Exception
      Connect to Postgres with the database properties passed in. This is useful when re-running component tests with the containers left up between runs and not wanting to set the system properties for each test run.
      Throws:
      Exception
    • close

      public static void close(Connection connection) throws Exception
      Close the Postgres connection.
      Throws:
      Exception
    • getDbHostAndPortUrl

      public static String getDbHostAndPortUrl()
      Get the URL of the database with the host and port. The port is the mapped port of the docker container, such that this can be used to connect to from the tests.