Package com.invirgance.convirgance.jdbc
Class AutomaticDriver
java.lang.Object
com.invirgance.convirgance.jdbc.AutomaticDriver
Provides access to a vendor-specific database driver. Supports both
java.sql.Driver
and javax.sql.DataSource
.- Author:
- jbanes
-
Method Summary
Modifier and TypeMethodDescriptioncreateConnection
(String name) Create a new StoredConnection for permanently recording a connection to an external database.void
delete()
Permanently remove this driver configuration from the driver listString[]
Returns the artifacts that will be loaded from maven.getConfiguration
(String key, String defaultValue) Return the requested driver configuration value, or the provided default value if the configuration is not found.Returns an unconfiguredDataSource
instance for this database.Return the class name of the DataSource without initializing the objectReturn the class name of the Driver without initializing the objectString[]
getName()
String[]
Returns the prefixes that can be used in connection URLs.quoteIdentifier
(String name) Natively quotes an identifier for use in a SQL statement.void
save()
Persist changes of the driver configuration to the driver listvoid
setArtifacts
(String... artifacts) Set the maven artifacts for the driver, these will be used to load the driver.void
setDataSource
(String dataSourceClass) Sets the DataSource the Driver will use when creating connections.void
void
setExamples
(String... examples) Set the connection URL examples for the driver.void
setPrefixes
(String... prefixes) Update the prefixes used by the Driver to connect to the Database.toString()
-
Method Details
-
getName
-
getDriver
-
setDriver
-
getDriverClassName
Return the class name of the Driver without initializing the object- Returns:
- the name of the Driver class
-
getDataSource
Returns an unconfiguredDataSource
instance for this database. Consult the documentation for the database to find what properties are available to setup the connection.- Returns:
- an unconfigured
DataSource
- See Also:
-
setDataSource
Sets the DataSource the Driver will use when creating connections.- Parameters:
dataSourceClass
- The full class name of the data source
-
getDataSourceClassName
Return the class name of the DataSource without initializing the object- Returns:
- the name of the DataSource class
-
getArtifacts
Returns the artifacts that will be loaded from maven. Note: Some Drivers do not include the DataSource.- Returns:
- The artifacts coordinates.
-
setArtifacts
Set the maven artifacts for the driver, these will be used to load the driver. Include the full artifact coordinates.- Parameters:
artifacts
- Artifacts
-
getPrefixes
Returns the prefixes that can be used in connection URLs.- Returns:
- URL prefix strings
-
setPrefixes
Update the prefixes used by the Driver to connect to the Database.- Parameters:
prefixes
- Strings that represent connection URL prefixes.
-
getExamples
-
setExamples
Set the connection URL examples for the driver.- Parameters:
examples
- URL Strings showcasing the connection URL for the driver.
-
getConfiguration
Return the requested driver configuration value, or the provided default value if the configuration is not found.- Parameters:
key
- the configuration value to retrievedefaultValue
- the value to return if the key is not configured- Returns:
- the configuration value if available, or the default value otherwise
-
quoteIdentifier
Natively quotes an identifier for use in a SQL statement. If the identifier contains the quote character, the quote character will be escaped by doubling the instance of the character. e.g.This "Thing"
is quoted as"This ""Thing"""
.- Parameters:
name
- value to quote- Returns:
- the quoted value
-
createConnection
Create a new StoredConnection for permanently recording a connection to an external database. Returns a builder object to allow for rapid configuration of the connection. Connection will not be saved untilStoredConnection.save()
is called.- Parameters:
name
- a unique name that can be used to later retrieve the connection- Returns:
- a builder for configuring the new connection
-
save
public void save() throws com.invirgance.convirgance.ConvirganceExceptionPersist changes of the driver configuration to the driver list- Throws:
com.invirgance.convirgance.ConvirganceException
- if configured drivers cannot be loaded or there is a database conflict
-
delete
public void delete() throws com.invirgance.convirgance.ConvirganceExceptionPermanently remove this driver configuration from the driver list- Throws:
com.invirgance.convirgance.ConvirganceException
- if configured drivers cannot be loaded or there is a database conflict
-
toString
-