Package com.invirgance.convirgance.jdbc
Class StoredConnection
java.lang.Object
com.invirgance.convirgance.jdbc.StoredConnection
Represents a customized stored connection for interacting with databases.
To create a StoredConnection use the
StoredConnections.StoredConnectionBuilder
returned by AutomaticDriver.createConnection(String)
.- Author:
- jbanes
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Represents the data source configuration for a driver.class
-
Method Summary
Modifier and TypeMethodDescriptionvoid
delete()
Permanently deletes this connection from the repository of stored connectionsvoid
execute
(ConnectionCallback callback) Obtains a connection to the database, executes the callback, and then closes the connection.Attempts to get a connection to the database using the data source configuration.Returns the data source for the driver used by this StoredConnection.Returns the current driver's data source configuration.com.invirgance.convirgance.dbms.DBMS
getDBMS()
Returns a new DBMS setup specifically for this StoredConnection.Returns the driver (AutomaticDriver) in use.Returns the current driver configuration.getName()
Returns the name that this StoredConnection is recognized by.Returns the DatabaseSchemaLayout from this connection's driver and data source.void
save()
Persist any changes to the connection configuration.toString()
-
Method Details
-
getName
Returns the name that this StoredConnection is recognized by.- Returns:
- The name.
-
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
Returns the current driver configuration. Use this to update/retrieve driver information such as the username, password or URl.- Returns:
- The drivers configuration.
-
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
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
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
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
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
-