Class AutomaticDriver

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

public class AutomaticDriver extends Object
Provides access to a vendor-specific database driver. Supports both java.sql.Driver and javax.sql.DataSource.
Author:
jbanes
  • Method Details

    • getName

      public String getName()
    • getDriver

      public Driver getDriver()
    • setDriver

      public void setDriver(String driverClass)
    • getDriverClassName

      public String getDriverClassName()
      Return the class name of the Driver without initializing the object
      Returns:
      the name of the Driver class
    • getDataSource

      public DataSource getDataSource()
      Returns an unconfigured DataSource 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

      public void setDataSource(String dataSourceClass)
      Sets the DataSource the Driver will use when creating connections.
      Parameters:
      dataSourceClass - The full class name of the data source
    • getDataSourceClassName

      public String getDataSourceClassName()
      Return the class name of the DataSource without initializing the object
      Returns:
      the name of the DataSource class
    • getArtifacts

      public String[] getArtifacts()
      Returns the artifacts that will be loaded from maven. Note: Some Drivers do not include the DataSource.
      Returns:
      The artifacts coordinates.
    • setArtifacts

      public void setArtifacts(String... artifacts)
      Set the maven artifacts for the driver, these will be used to load the driver. Include the full artifact coordinates.
      Parameters:
      artifacts - Artifacts
    • getPrefixes

      public String[] getPrefixes()
      Returns the prefixes that can be used in connection URLs.
      Returns:
      URL prefix strings
    • setPrefixes

      public void setPrefixes(String... prefixes)
      Update the prefixes used by the Driver to connect to the Database.
      Parameters:
      prefixes - Strings that represent connection URL prefixes.
    • getExamples

      public String[] getExamples()
    • setExamples

      public void setExamples(String... examples)
      Set the connection URL examples for the driver.
      Parameters:
      examples - URL Strings showcasing the connection URL for the driver.
    • getConfiguration

      public String getConfiguration(String key, String defaultValue)
      Return the requested driver configuration value, or the provided default value if the configuration is not found.
      Parameters:
      key - the configuration value to retrieve
      defaultValue - the value to return if the key is not configured
      Returns:
      the configuration value if available, or the default value otherwise
    • quoteIdentifier

      public String quoteIdentifier(String name)
      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

      public StoredConnections.StoredConnectionBuilder createConnection(String name)
      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 until StoredConnection.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.ConvirganceException
      Persist 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.ConvirganceException
      Permanently 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

      public String toString()
      Overrides:
      toString in class Object