Dynamic JDBC driver loading based on active database configurations.
This namespace provides configuration-driven driver loading that eliminates the need to coordinate between configuration files and command-line aliases. Drivers are loaded dynamically based on which databases are marked as :active in the configuration files.
Key Features:
Usage: (require '[wagoe.platform.shell.adapters.database.utils.driver-loader :as dl])
;; Load drivers for active databases in current environment (dl/load-required-drivers!)
;; Load drivers for specific environment (dl/load-drivers-for-environment! "dev")
Dynamic JDBC driver loading based on active database configurations. This namespace provides configuration-driven driver loading that eliminates the need to coordinate between configuration files and command-line aliases. Drivers are loaded dynamically based on which databases are marked as :active in the configuration files. Key Features: - Single source of truth: configuration files control everything - Clear error messages when drivers are missing - Automatic driver detection from active databases - No command-line alias coordination required Usage: (require '[wagoe.platform.shell.adapters.database.utils.driver-loader :as dl]) ;; Load drivers for active databases in current environment (dl/load-required-drivers!) ;; Load drivers for specific environment (dl/load-drivers-for-environment! "dev")
(adapter-key->driver-class adapter-key)Get JDBC driver class name for database adapter key.
Args: adapter-key: Database adapter keyword (:sqlite, :postgresql, :mysql, :h2)
Returns: String - JDBC driver class name
Example: (adapter-key->driver-class :sqlite) ;; => "org.sqlite.JDBC"
Get JDBC driver class name for database adapter key. Args: adapter-key: Database adapter keyword (:sqlite, :postgresql, :mysql, :h2) Returns: String - JDBC driver class name Example: (adapter-key->driver-class :sqlite) ;; => "org.sqlite.JDBC"
(attempt-driver-load driver-class)Attempt to load a JDBC driver class.
Args: driver-class: JDBC driver class name string
Returns: Map with :success boolean and :error string if failed
Example: (attempt-driver-load "org.sqlite.JDBC") ;; => {:success true} or {:success false :error "ClassNotFoundException"}
Attempt to load a JDBC driver class.
Args:
driver-class: JDBC driver class name string
Returns:
Map with :success boolean and :error string if failed
Example:
(attempt-driver-load "org.sqlite.JDBC")
;; => {:success true} or {:success false :error "ClassNotFoundException"}(config-key->adapter-key config-key)Extract adapter type from configuration key.
Args: config-key: Configuration key like :wagoe/sqlite
Returns: Keyword - adapter key like :sqlite
Example: (config-key->adapter-key :wagoe/sqlite) ;; => :sqlite
Extract adapter type from configuration key. Args: config-key: Configuration key like :wagoe/sqlite Returns: Keyword - adapter key like :sqlite Example: (config-key->adapter-key :wagoe/sqlite) ;; => :sqlite
(determine-required-drivers config)Determine which JDBC drivers are required for active databases.
Args: config: Configuration map with :active section
Returns: Set of JDBC driver class names required
Example: (determine-required-drivers config) ;; => #{"org.sqlite.JDBC" "org.h2.Driver"}
Determine which JDBC drivers are required for active databases.
Args:
config: Configuration map with :active section
Returns:
Set of JDBC driver class names required
Example:
(determine-required-drivers config)
;; => #{"org.sqlite.JDBC" "org.h2.Driver"}(format-dependency-coordinate {:keys [group-id artifact-id version]})Format Maven dependency coordinate for display.
Args: dep-info: Map with :group-id, :artifact-id, :version
Returns: String - formatted dependency coordinate
Format Maven dependency coordinate for display. Args: dep-info: Map with :group-id, :artifact-id, :version Returns: String - formatted dependency coordinate
(get-active-database-summary env)Get summary of active databases and their driver requirements.
Args: env: Environment string
Returns: Map with environment info, active databases, and driver requirements
Get summary of active databases and their driver requirements. Args: env: Environment string Returns: Map with environment info, active databases, and driver requirements
(get-dependency-suggestion driver-class)Get dependency suggestion for missing driver.
Args: driver-class: JDBC driver class name
Returns: String - formatted dependency suggestion or nil if unknown
Get dependency suggestion for missing driver. Args: driver-class: JDBC driver class name Returns: String - formatted dependency suggestion or nil if unknown
(load-drivers-for-current-environment!)Load JDBC drivers for active databases in current environment.
Returns: Result map from load-required-drivers!
Load JDBC drivers for active databases in current environment. Returns: Result map from load-required-drivers!
(load-drivers-for-environment! env)Load JDBC drivers required for active databases in specified environment.
Args: env: Environment string (e.g. "dev", "test", "prod")
Returns: Result map from load-required-drivers!
Example: (load-drivers-for-environment! "dev")
Load JDBC drivers required for active databases in specified environment. Args: env: Environment string (e.g. "dev", "test", "prod") Returns: Result map from load-required-drivers! Example: (load-drivers-for-environment! "dev")
(load-required-drivers! config)Load all JDBC drivers required by active databases in configuration.
Args: config: Configuration map with :active section
Returns: Map with :success boolean, :loaded vector of loaded drivers, :failed vector of failed drivers with error info
Throws: ExceptionInfo if any required drivers cannot be loaded
Load all JDBC drivers required by active databases in configuration. Args: config: Configuration map with :active section Returns: Map with :success boolean, :loaded vector of loaded drivers, :failed vector of failed drivers with error info Throws: ExceptionInfo if any required drivers cannot be loaded
(validate-drivers-available config)Validate that all required drivers are available without loading them.
Args: config: Configuration map with :active section
Returns: Map with :valid boolean and :missing vector of missing driver info
Validate that all required drivers are available without loading them. Args: config: Configuration map with :active section Returns: Map with :valid boolean and :missing vector of missing driver info
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |