Class GenericJDBCDriver

java.lang.Object
ortus.boxlang.runtime.jdbc.drivers.GenericJDBCDriver
All Implemented Interfaces:
IJDBCDriver

public class GenericJDBCDriver extends Object implements IJDBCDriver
This is the generic JDBC driver that can be used to register datasources in the system. We use a generic JDBC Url connection schema to connect to the database.
  • Field Details

    • name

      protected Key name
      The unique name of the driver
    • type

      protected DatabaseDriverType type
      The driver type according to BoxLang standards
    • driverClassName

      protected String driverClassName
      The class name of the driver, useful metadata
    • defaultDelimiter

      protected String defaultDelimiter
      The default delimiter for the custom parameters
    • defaultPort

      protected String defaultPort
      A default port for the connection URL, if needed. Null by default.
    • defaultHost

      protected String defaultHost
      A default host for the connection URL, if needed. Localhost by default.
    • defaultCustomParams

      protected IStruct defaultCustomParams
      The default custom params for the connection URL These are attached to the connection URL as query parameters according to the driver's requirements.
    • defaultProperties

      protected IStruct defaultProperties
      The default configuration properties. These are attached to the datasource configuration as properties Which can be used by our Connection Pool: HikariCP
  • Constructor Details

    • GenericJDBCDriver

      public GenericJDBCDriver()
      Constructor
  • Method Details

    • getName

      public Key getName()
      -------------------------------------------------------------------------- Interface Methods --------------------------------------------------------------------------
      Specified by:
      getName in interface IJDBCDriver
    • getType

      public DatabaseDriverType getType()
      Description copied from interface: IJDBCDriver
      Get the driver type
      Specified by:
      getType in interface IJDBCDriver
    • getClassName

      public String getClassName()
      We return an empty class, because we are using a generic JDBC driver that does not have a specific class name.

      This will be based on the connection url built by the driver and it will be expecting the class to be in the class path.

      Custom parameters are incorporated by the DatasourceConfig object automatically.

      Specified by:
      getClassName in interface IJDBCDriver
    • buildConnectionURL

      public String buildConnectionURL(DatasourceConfig config)
      Description copied from interface: IJDBCDriver
      Get the connection JDBC URL according to the driver type. The driver implementation should be able to build the connection URL
      Specified by:
      buildConnectionURL in interface IJDBCDriver
    • getDefaultProperties

      public IStruct getDefaultProperties()
      Get default properties for the driver to incorporate into the datasource config
      Specified by:
      getDefaultProperties in interface IJDBCDriver
    • getDefaultCustomParams

      public IStruct getDefaultCustomParams()
      Get default custom parameters for the driver to incorporate into the datasource config
      Specified by:
      getDefaultCustomParams in interface IJDBCDriver
    • getDefaultPort

      public String getDefaultPort()
      Get the default port for the driver
      Returns:
      The default port
    • getDefaultHost

      public String getDefaultHost()
      Get the default host for the driver
      Returns:
      The default host
    • getDefaultDelimiter

      public String getDefaultDelimiter()
      Get the default delimiter for the custom parameters
      Returns:
      The default delimiter
    • customParamsToQueryString

      public String customParamsToQueryString(DatasourceConfig config)
      This helper method is used to convert the custom parameters in the config (Key.custom) to a query string that can be used by the driver to build the connection URL.

      We incorporate the default parameters into the custom parameters and return the query string using the driver's default delimiter.

      Parameters:
      config - The datasource config
      Returns:
      The custom parameters as a query string