Class StoredConnection

java.lang.Object
com.invirgance.convirgance.jdbc.StoredConnection

public class StoredConnection extends Object
Represents a customized stored connection for interacting with databases. To create a StoredConnection use the StoredConnections.StoredConnectionBuilder returned by AutomaticDriver.createConnection(String).
Author:
jbanes
  • Method Details

    • getName

      public String getName()
      Returns the name that this StoredConnection is recognized by.
      Returns:
      The name.
    • getDriver

      public AutomaticDriver getDriver()
      Returns the driver (AutomaticDriver) in use. Use the returned object to update the behavior of this driver along with its DataSource, Artifacts etc...
      Returns:
      The driver.
    • getDriverConfig

      public StoredConnection.DriverConfig getDriverConfig()
      Returns the current driver configuration. Use this to update/retrieve driver information such as the username, password or URl.
      Returns:
      The drivers configuration.
    • getDataSourceConfig

      public StoredConnection.DataSourceConfig getDataSourceConfig()
      Returns the current driver's data source configuration. If no configuration exists the DataSourceConfig will be created using the defaults for ALL properties.
      Returns:
      The data source configuration.
    • getConnection

      public Connection getConnection()
      Attempts to get a connection to the database using the data source configuration. Will throw an exception if the connection fails.
      Returns:
      A connection to the database.
    • execute

      public void execute(ConnectionCallback callback)
      Obtains a connection to the database, executes the callback, and then closes the connection.
      Parameters:
      callback - a callback containing the logic to execute against the database
      Throws:
      com.invirgance.convirgance.ConvirganceException - if an SQL error occurs
    • getDataSource

      public DataSource getDataSource()
      Returns the data source for the driver used by this StoredConnection. If the drivers configuration lacks a data source a new one is assigned based on the URL's prefix.
      Returns:
      The data source.
    • getDBMS

      public com.invirgance.convirgance.dbms.DBMS getDBMS()
      Returns a new DBMS setup specifically for this StoredConnection. Used to act on the database.
      Returns:
      A DBMS for executing queries etc...
    • getSchemaLayout

      public DatabaseSchemaLayout getSchemaLayout()
      Returns the DatabaseSchemaLayout from this connection's driver and data source. This can be used to interact with tables, views, and metadata of the schema.
      Returns:
      DatabaseSchemaLayout.
    • save

      public void save()
      Persist any changes to the connection configuration. If this is a new connection, the connection will not be saved until this is called.
    • delete

      public void delete()
      Permanently deletes this connection from the repository of stored connections
    • toString

      public String toString()
      Overrides:
      toString in class Object