Class DatabaseConnection

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class DatabaseConnection
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Create a PostgreSQL database connection
    • Constructor Summary

      Constructors 
      Constructor Description
      DatabaseConnection​(java.lang.String connectionUrl)
      Default constructor takes in a url of the form host[:port]/database.
    • Constructor Detail

      • DatabaseConnection

        public DatabaseConnection​(java.lang.String connectionUrl)
        Default constructor takes in a url of the form host[:port]/database. Port and additional query params are optional; i.e, localhost/database would default to port 5432. Also, additional query parameters can be appended to the database name; i.e. localhost/database?user=postgres&currentSchema=public&password=private
        Parameters:
        connectionUrl - a database url
        See Also:
        JDBC connection parameters
    • Method Detail

      • close

        public void close()
                   throws java.sql.SQLException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.sql.SQLException
      • getConnection

        public java.sql.Connection getConnection()
                                          throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • getConnectionURI

        public java.net.URI getConnectionURI()
      • getQueryParameters

        public java.util.Map<java.lang.String,​java.lang.String> getQueryParameters()
      • getSchema

        public java.lang.String getSchema()