### Create MySQL Database and Grant Permissions Source: https://github.com/clojure/java.jdbc/blob/master/README.md These SQL commands are used to create a new database and grant all privileges on it to a specific user in MySQL. This setup is typical for preparing a database environment for application testing. ```SQL create database clojure_test; grant all on clojure_test.* to clojure_test identified by "clojure_test"; ``` -------------------------------- ### Define PostgreSQL Connection URI in Clojure Source: https://github.com/clojure/java.jdbc/blob/master/README.md This example demonstrates defining a PostgreSQL database specification using a full connection URI. This method provides a concise way to specify connection details, including host, port, database, user, password, and SSL options. ```Clojure (def pg-uri {:connection-uri (str "postgresql://myuser:secret@mydb.server.com:5432/mypgdatabase" "?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory")}) ``` -------------------------------- ### DSL Namespace Retirement Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The DSL namespaces introduced in 0.3.0-alpha1 have been retired. Users are advised to migrate to external DSL libraries, with a migration guide available. ```APIDOC DSL Namespaces: Status: Retired (as of 0.3.0-beta2) Migration: Refer to https://github.com/seancorfield/jsql. ``` -------------------------------- ### Execute Database Query with Row Function in Clojure Source: https://github.com/clojure/java.jdbc/blob/master/README.md This example shows how to execute a parameterized SQL query using `j/query` and process the results with a `:row-fn`. The `:row-fn` transforms each row of the result set, in this case, extracting only the `:cost` column. ```Clojure (j/query mysql-db ["select * from fruit where appearance = ?" "rosy"] {:row-fn :cost}) ;; (24) ``` -------------------------------- ### Clojure db-transaction Macro for Atomic Database Operations Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md This snippet demonstrates the usage of the `db-transaction` macro in Clojure's `java.jdbc` library. It provides a transactional context for database operations, ensuring atomicity and the ability to roll back changes if an error occurs. The example shows a simple `query` execution within the transaction scope. ```Clojure (db-transaction [t-con db-spec] (query t-con (select * :user (where {:id 42})))) ``` -------------------------------- ### Create PostgreSQL User and Database for Testing Source: https://github.com/clojure/java.jdbc/blob/master/README.md These shell commands demonstrate how to set up a new user and database in PostgreSQL for testing purposes. The `createuser` command creates a user with a password, and `createdb` creates a database owned by that user. ```Bash $ sudo -u postgres createuser clojure_test -P clojure_test $ sudo -u postgres createdb clojure_test -O clojure_test ``` -------------------------------- ### Clojure java.jdbc: Query Performance Analysis Options Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `query`, `find-by-keys`, and `get-by-id` functions now support `:explain?` and `:explain-fn` options. These options facilitate basic performance analysis by allowing users to request query explanations and provide a custom function to process them. ```APIDOC query(sql-params: any, options: map) find-by-keys(table: string, keys: map, options: map) get-by-id(table: string, id: any, options: map) Options: :explain? (boolean): If true, requests a query explanation. :explain-fn (function): A function to process the query explanation result. ``` -------------------------------- ### Clojure java.jdbc: Query Options for PreparedStatement Construction Source: https://github.com/clojure/java.jdbc/blob/master/README.md The options map provided to the `query` function is now passed through to `db-query-with-resultset`, allowing `query` to accept options for constructing the `PreparedStatement`. ```APIDOC query(sql-params: any, options: map) Options: (map): Options passed to db-query-with-resultset, which can be used to construct the PreparedStatement. ``` -------------------------------- ### Allow PreparedStatement in db-do-prepared-return-keys Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `db-do-prepared-return-keys` function now accepts a `PreparedStatement` as an argument, enhancing flexibility for prepared statement usage. ```APIDOC db-do-prepared-return-keys(db-spec, prepared-statement: PreparedStatement, ...) // Now accepts a PreparedStatement as an argument. ``` -------------------------------- ### Run Maven Tests Against Specific Databases Source: https://github.com/clojure/java.jdbc/blob/master/README.md This shell command shows how to execute Maven tests while specifying which databases to test against using the `TEST_DBS` environment variable. This allows for targeted testing of database integrations. ```Bash $ TEST_DBS="mysql postgres" mvn test ``` -------------------------------- ### Add metadata-query Macro for Easier Metadata Handling Source: https://github.com/clojure/java.jdbc/blob/master/README.md A new `metadata-query` macro has been added to simplify working with database metadata queries and their results. ```Clojure (metadata-query & args) ``` -------------------------------- ### Clojure java.jdbc: db-query-with-resultset Parameter Flexibility Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `db-query-with-resultset` function now accepts an options map, which is passed to `prepare-statement`. It also accepts a sequence for `sql-params` and a bare SQL string or `PreparedStatement` when no parameters are needed. Note that passing the options map as the first element of the `[sql & params]` vector is no longer supported. ```APIDOC db-query-with-resultset(options: map, sql-params: any) Parameters: options (map): Options passed to prepare-statement. sql-params (seq | string | PreparedStatement): - A sequence of SQL and parameters. - A bare SQL string or PreparedStatement when no parameters are required. Deprecated: Passing options as the first element of the '[sql & params]' vector is no longer supported. ``` -------------------------------- ### Enhance prepare-statement :return-keys for Column Names Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `:return-keys` option for `prepare-statement` can now be a vector of auto-generated column names to return, in addition to just a truthy or falsey value. This allows keys to be returned for more databases. ```APIDOC prepare-statement(sql, options: map) Options: :return-keys: boolean | vector - boolean (true/false): Return all/no auto-generated keys. - vector: Return keys for specified auto-generated column names (e.g., ["id", "uuid"]). ``` -------------------------------- ### Support HSQLDB and SQLite In-Memory Connection Strings Source: https://github.com/clojure/java.jdbc/blob/master/README.md HSQLDB and SQLite in-memory connection strings are now accepted for database connections, facilitating in-memory database usage for testing or temporary data storage. ```APIDOC // Database connection strings now accept HSQLDB and SQLite in-memory formats. // Examples: // "jdbc:hsqldb:mem:mymemdb" // "jdbc:sqlite::memory:" ``` -------------------------------- ### Update db-do-prepared and db-do-prepared-return-keys Parameters Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `db-do-prepared` and `db-do-prepared-return-keys` functions now expect a `db-spec`, an optional `transaction?` boolean, a `sql-params` argument (which can be a vector of SQL string/PreparedStatement and parameters, or a vector of parameter groups), and an optional options map. Calling these functions with unrolled arguments is deprecated. ```APIDOC db-do-prepared(db-spec, [transaction?: boolean], sql-params: vector, [options: map]) db-do-prepared-return-keys(db-spec, [transaction?: boolean], sql-params: vector, [options: map]) Parameters: db-spec: Database specification. transaction?: Optional boolean, indicates if transaction is used. sql-params: Vector containing SQL string/PreparedStatement followed by parameters, or a vector of parameter groups. - Format 1: [sql-string | PreparedStatement, param1, param2, ...] - Format 2 (multi-parameter): [[param_group1_val1, ...], [param_group2_val1, ...], ...] options: Optional map for additional settings. Deprecated: - Calling with unrolled arguments (SQL string / statement followed by parameter groups directly). ``` -------------------------------- ### Define Database Connection Specifications in Clojure Source: https://github.com/clojure/java.jdbc/blob/master/README.md This Clojure code illustrates how to define database connection specifications (db-spec maps) for MySQL and PostgreSQL using `clojure.java.jdbc`. It covers essential parameters like `dbtype`, `dbname`, `user`, `password`, and advanced options such as `host`, `port`, `ssl`, and `sslfactory` for secure connections. It also notes the option to explicitly provide a JDBC driver `classname`. ```Clojure (require '[clojure.java.jdbc :as j]) ;; there are many ways to write a db-spec but the easiest way is to ;; use :dbtype and then provide the :dbname and any of :user, :password, ;; :host, :port, and other options as needed: (def mysql-db {:dbtype "mysql" :dbname "clojure_test" :user "clojure_test" :password "clojure_test"}) (def pg-db {:dbtype "postgresql" :dbname "mypgdatabase" :host "mydb.server.com" :user "myuser" :password "secret" :ssl true :sslfactory "org.postgresql.ssl.NonValidatingFactory"}) ;; if the dbtype is not known to clojure.java.jdbc, or you want to override the ;; default choice of JDBC driver class name, you can provide :classname and the ;; name of the class to use: ``` -------------------------------- ### Update create-table-ddl Column Spec and Options Handling Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `create-table-ddl` function now requires column specifications to be wrapped in a single vector. The `:options` delimiter is no longer needed for the options map. Using unwrapped column specs or the `:options` delimiter will issue a deprecation warning. ```APIDOC create-table-ddl(table-name, column-specs: vector, options: map) Parameters: table-name: Name of the table to create. column-specs: Vector of column specifications. - Required format: [col-spec1, col-spec2, ...] options: Map for table creation options. Deprecated: - Not wrapping column specs in a single vector. - Using :options as a delimiter for the options map. ``` -------------------------------- ### Clojure java.jdbc: New Convenience Functions get-by-id and find-by-keys Source: https://github.com/clojure/java.jdbc/blob/master/README.md New convenience functions `get-by-id` and `find-by-keys` have been added to the core library. These functions simplify common database operations, with `find-by-keys` supporting an `:order-by` option for specifying query ordering. ```APIDOC get-by-id(table: string, id: any, options: map) find-by-keys(table: string, keys: map, options: map) find-by-keys Options: :order-by (seq): A sequence of orderings; an ordering is a column name (keyword) or a map from column name (keyword) to direction (:asc or :desc). ``` -------------------------------- ### Enhance `prepare-statement` `:return-keys` Option Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `:return-keys` option for `prepare-statement` now supports a vector of auto-generated column names to be returned, in addition to just being truthy or falsey. This allows keys to be returned for a wider range of databases. ```APIDOC prepare-statement Parameter: :return-keys (boolean | vector of column names) - true/false: Return auto-generated keys (if supported). - ["col1" "col2"]: Return specific auto-generated column names. ``` -------------------------------- ### Enable `execute!` to Accept a PreparedStatement Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `execute!` function can now directly accept a `PreparedStatement` object as an argument, enhancing its flexibility and allowing for more direct execution of pre-compiled SQL statements. ```APIDOC execute! Signature: (execute! db-spec prepared-statement & params) - prepared-statement: A java.sql.PreparedStatement object. ``` -------------------------------- ### Introduce `get-by-id` and Enhance `find-by-keys` with `:order-by` Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md New convenience functions `get-by-id` and `find-by-keys` have been added. `find-by-keys` now also supports an `:order-by` option, allowing flexible sorting by column names or specific ascending/descending orders. ```APIDOC get-by-id: description: "Convenience function for retrieving records by ID." find-by-keys: description: "Convenience function for retrieving records by keys." options: :order-by: type: "sequence" description: "Specifies a sequence of orderings." elements: - type: "column-name" description: "Sorts by column in ascending order." - type: "{column-name: :asc | :desc}" description: "Sorts by column with specified ascending or descending order." ``` -------------------------------- ### Enhance `db-query-with-resultset` Argument Flexibility Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `db-query-with-resultset` function now accepts a sequence for `sql-params` (instead of just a vector) and can take a bare SQL string or `PreparedStatement` when no parameters are needed. The options map from `query` is also now passed through. ```APIDOC db-query-with-resultset: sql-params: - type: "sequence" description: "Accepts a sequence of parameters (previously only vector)." - type: "string | PreparedStatement" description: "Accepts a bare SQL string or PreparedStatement when no parameters are needed." options: - description: "Options map from `query` is now passed through for PreparedStatement construction." ``` -------------------------------- ### Add `metadata-query` Macro for Clojure JDBC Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md A new macro, `metadata-query`, has been added to simplify working with database metadata queries and their results, making it easier to extract and process schema information. ```APIDOC metadata-query Purpose: Simplifies querying and processing database metadata. Usage: (metadata-query db-spec & body) ``` -------------------------------- ### Clojure java.jdbc: db-do-commands Multiple Commands Format Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `db-do-commands` function now expects multiple commands to be wrapped in a single vector. While the single command form remains unchanged (and can also be wrapped), calling with multiple unwrapped commands will issue a deprecation warning. ```APIDOC db-do-commands(commands: seq) Parameters: commands (seq): A sequence of SQL commands. Multiple commands must be wrapped in a single vector: (db-do-commands ["CREATE TABLE..." "INSERT INTO..."]) Single commands can be bare or wrapped: (db-do-commands "CREATE TABLE...") (db-do-commands ["CREATE TABLE..."]) Deprecated Behavior: Calling with multiple commands not wrapped in a single vector will produce a "DEPRECATED" warning. ``` -------------------------------- ### Revise Arguments for `db-do-prepared` and `db-do-prepared-return-keys` Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md These functions now expect a `db-spec`, optional `transaction?`, a `sql-params` vector (SQL/PreparedStatement + params), and an optional options map. They also support a vector of parameter groups for multi-execution. The previous unrolled argument form is deprecated. ```APIDOC db-do-prepared, db-do-prepared-return-keys: signature: "(db-spec, ?transaction?, sql-params, ?options?)" sql-params: type: "vector" content: "[SQL-string | PreparedStatement, param1, param ``` -------------------------------- ### Clojure java.jdbc: find-by-keys Nil Value and Order By Handling Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `find-by-keys` function now correctly handles `nil` values in its input. Additionally, it treats an empty sequence (`[]`) for the `:order-by` option as no `ORDER BY` clause, providing more intuitive control over query ordering. ```APIDOC find-by-keys(table: string, keys: map, options: map) Behavior: Correctly handles nil values within the 'keys' map. Options: :order-by (seq): A sequence of orderings. An empty sequence '[]' is treated as no ORDER BY clause. ``` -------------------------------- ### Creating Table with Custom Engine Specification in Clojure Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Demonstrates how to create a database table using `sql/create-table` and specify a custom table engine or other table-specific options via the `:table-spec` argument. This addresses JDBC-2 by allowing a string for table specifications at the end of the arguments, such as 'ENGINE=MyISAM'. ```Clojure (sql/create-table :foo [:col1 "int"] ["col2" :int] :table-spec "ENGINE=MyISAM") ``` -------------------------------- ### Implement Nil Protocol for `ISQLParameter` Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md A `nil` protocol implementation has been added for `ISQLParameter`, improving the handling of null values when setting parameters in prepared statements, ensuring consistent behavior. ```APIDOC ISQLParameter Protocol: Extends ISQLParameter to handle nil values gracefully. ``` -------------------------------- ### Clojure CLI/deps.edn Dependency for clojure.java.jdbc Source: https://github.com/clojure/java.jdbc/blob/master/README.md This snippet shows the `deps.edn` configuration required to add `clojure.java.jdbc` as a dependency in a Clojure project using the Clojure CLI tool. It specifies the `org.clojure/java.jdbc` artifact with version `0.7.12`. ```Clojure org.clojure/java.jdbc {:mvn/version "0.7.12"} ``` -------------------------------- ### order-by Empty Sequence Handling Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `order-by` function now correctly handles empty sequences as input, returning an empty string. ```APIDOC order-by (columns) Input: Accepts empty sequence. Output: Returns empty string for empty input. ``` -------------------------------- ### Clojure java.jdbc: Insert Functions with Identifiers and Qualifiers Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `insert!` and `insert-multi!` functions now correctly respect the `:identifiers` and `:qualifier` options. This change addresses behavior on PostgreSQL where inserting rows returns full rows, ensuring proper handling of returned data and keyword construction from SQL column names. ```APIDOC insert!(table: string, row: map, options: map) insert-multi!(table: string, rows: seq, options: map) Options: :identifiers (seq): A sequence of column names to be treated as identifiers. :qualifier (string): A namespace qualifier to use when constructing keywords from SQL column names. ``` -------------------------------- ### clojure.java.jdbc.ddl Namespace Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md A new namespace, `clojure.java.jdbc.ddl`, is introduced for DDL functions like `create-table`, `drop-table`, `create-index`, and `drop-index`. Corresponding functions in the main namespace are deprecated. ```APIDOC Namespace: clojure.java.jdbc.ddl Functions: create-table (table-name columns & options) drop-table (table-name & options) create-index (index-name table-name columns & options) drop-index (index-name table-name & options) Deprecated in main namespace: create-table create-table-ddl drop-table ``` -------------------------------- ### Standardize Options Map Usage in Clojure java.jdbc Source: https://github.com/clojure/java.jdbc/blob/master/README.md All calls that previously accepted optional keyword arguments now allow an options map instead. The unrolled keyword argument forms are deprecated and will be removed in version 0.6.0. ```APIDOC // General API change: // Functions now accept an options map instead of unrolled keyword arguments. // Example: func(arg1, arg2, {:option1 val1, :option2 val2}) Deprecated: - Unrolled keyword argument forms (e.g., func(arg1, arg2, :option1 val1, :option2 val2)). ``` -------------------------------- ### Support Simplified Database Specification (`db-spec`) Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Database specifications now support a simpler format using `:dbtype` and `:dbname`, with optional `:host` and `:port` parameters, streamlining connection configurations and reducing verbosity. ```APIDOC db-spec Format: {:dbtype "type" :dbname "name" :host "host" :port "port" ...} - :dbtype: Database type (e.g., "h2", "postgresql"). - :dbname: Database name. - :host: Optional, database host. - :port: Optional, database port. ``` -------------------------------- ### Allow Arbitrary Values for prepare-statement Cursor/Concurrency/Result-Type Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `:cursors`, `:concurrency`, and `:result-type` arguments to `prepare-statement` now allow arbitrary values, providing greater flexibility for statement configuration. ```APIDOC prepare-statement(sql, options: map) Options: :cursors: any // Allows arbitrary values for cursor type. :concurrency: any // Allows arbitrary values for concurrency type. :result-type: any // Allows arbitrary values for result set type. ``` -------------------------------- ### Add :timeout Argument to prepare-statement Source: https://github.com/clojure/java.jdbc/blob/master/README.md A new `:timeout` argument has been added to the `prepare-statement` function, allowing users to specify a statement timeout in seconds. ```APIDOC prepare-statement(sql, options: map) Options: :timeout: integer // Sets the statement timeout in seconds. ``` -------------------------------- ### Refactor insert! for Single Row and Introduce insert-multi! Source: https://github.com/clojure/java.jdbc/blob/master/README.md `insert!` now supports only single-row insertion; multi-row insertion is deprecated. `insert-multi!` has been added for multi-row insertion. The `:options` delimiter is no longer needed for the options map. Calling `insert!` with multiple rows or specifying `:options` will issue a deprecation warning. ```APIDOC insert!(db, table, columns: vector, values: vector, options: map) - Supports only single row insertion. - Deprecated: Multi-row insertion. - Deprecated: Using :options as a delimiter for the options map. insert-multi!(db, table, columns: vector, values: vector, options: map) - Added for multi-row insertion. ``` -------------------------------- ### Add `with-db-connection` Macro for Connection Management Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `with-db-connection` macro provides an easier way to group and execute operations against a single open database connection, ensuring proper resource management and connection closure. ```APIDOC with-db-connection Purpose: Macro for managing a single database connection. Usage: (with-db-connection [con db-spec] ...) ``` -------------------------------- ### Perform Multiple Row Inserts in Clojure Source: https://github.com/clojure/java.jdbc/blob/master/README.md This snippet illustrates how to insert multiple rows into a database table using `j/insert-multi!`. It takes the database specification, table name, and a collection of maps representing the rows to be inserted, returning a list of generated keys. ```Clojure (j/insert-multi! mysql-db :fruit [{:name "Apple" :appearance "rosy" :cost 24} {:name "Orange" :appearance "round" :cost 49}]) ;; ({:generated_key 1} {:generated_key 2}) ``` -------------------------------- ### API Deprecation and Relocation Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The older 0.2.3 API has been moved to `clojure.java.jdbc.deprecated` to streamline the main API for 0.3.0 and improve documentation. ```APIDOC Deprecated API: Location: clojure.java.jdbc.deprecated Original Version: 0.2.3. ``` -------------------------------- ### Define Redshift Database Specification in Clojure Source: https://github.com/clojure/java.jdbc/blob/master/README.md This snippet shows how to define a database specification map for a Redshift connection in Clojure. It includes the database type, name, and JDBC driver class name, which are essential for establishing a connection. ```Clojure (def redshift42 {:dbtype "redshift" :dbname "myredstore" :classname "com.amazon.redshift.jdbc42.Driver" ...}) ``` -------------------------------- ### Add `with-db-metadata` Macro for SQL Metadata Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `with-db-metadata` macro has been introduced to simplify working with SQL metadata, often used in conjunction with the `metadata-result` function for structured access to database schema information. ```APIDOC with-db-metadata Purpose: Macro to simplify access to database metadata. Usage: (with-db-metadata [md db-spec] ...) ``` -------------------------------- ### Add `:row-fn` and `:result-set-fn` to `metadata-result` Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `metadata-result` function now includes `:row-fn` and `:result-set-fn` options, allowing custom processing of individual rows and the entire result set returned from metadata queries. ```APIDOC metadata-result Parameter: :row-fn (function) - Applied to each row of the result set. Parameter: :result-set-fn (function) - Applied to the entire result set. ``` -------------------------------- ### Maven Dependency for clojure.java.jdbc Source: https://github.com/clojure/java.jdbc/blob/master/README.md This XML snippet demonstrates how to add `clojure.java.jdbc` as a dependency in a Maven project's `pom.xml`. It includes the `groupId`, `artifactId`, and `version` for the library. ```XML org.clojure java.jdbc 0.7.12 ``` -------------------------------- ### Leiningen Dependency for clojure.java.jdbc Source: https://github.com/clojure/java.jdbc/blob/master/README.md This snippet provides the Leiningen dependency declaration for `clojure.java.jdbc`. It specifies the `org.clojure/java.jdbc` artifact with version `0.7.12` to be included in a Leiningen project's `project.clj`. ```Clojure [org.clojure/java.jdbc "0.7.12"] ``` -------------------------------- ### Remove Deprecated Functions and Namespace in 0.6.0 Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md All previously deprecated functionality has been removed in the 0.6.0 release series. This includes specific features from `db-do-commands` and `db-do-prepared*`, the `db-transaction` function (deprecated since 0.3.0), and the entire `java.jdbc.deprecated` namespace. Users are advised to use version 0.5.8 as a bridge to identify and update any code relying on these removed APIs. ```APIDOC Deprecated Functionality Removal (0.6.0 series): db-do-commands: "Deprecated features removed." db-do-prepared*: "Deprecated features removed." db-transaction: "Removed (deprecated in 0.3.0)." java.jdbc.deprecated: "Namespace removed." Recommendation: "Use 0.5.8 as a bridge to identify deprecated API calls." ``` -------------------------------- ### Update `db-do-commands` for Multiple Commands Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `db-do-commands` function now requires multiple commands to be wrapped in a single vector. The single command form is unchanged but can also be wrapped. Calling with multiple un-wrapped commands will produce a deprecation warning. ```APIDOC db-do-commands: arguments: multiple-commands: "Must be wrapped in a single vector." single-command: "Unchanged, can optionally be wrapped in a vector." deprecation-warning: "Calling with multiple un-wrapped commands will produce a 'DEPRECATED' warning." ``` -------------------------------- ### execute! Function Multi-Operation Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `execute!` function now supports a `:multi?` option for performing repeated operations, enhancing batch processing. ```APIDOC execute! (db-spec sql-params & options) Options: :multi? - Enables repeated operations. ``` -------------------------------- ### NULL Value Handling Reversion Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Specialized handling of `NULL` values has been reverted, which reopens a previous issue related to database-specific `NULL` behavior. ```APIDOC NULL Value Handling: Status: Specialized handling reverted. ``` -------------------------------- ### DDL Entities Naming Strategy Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Data Definition Language (DDL) operations now support an entities naming strategy, providing more flexible naming conventions for database objects. ```APIDOC DDL Features: Entities Naming Strategy: Supported. ``` -------------------------------- ### Allow Arbitrary Values for `prepare-statement` Cursor/Concurrency/Result Type Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `prepare-statement` function now allows arbitrary values for its `:cursors`, `:concurrency`, and `:result-type` arguments, providing greater flexibility and control over statement behavior. ```APIDOC prepare-statement Parameter: :cursors (arbitrary value) Parameter: :concurrency (arbitrary value) Parameter: :result-type (arbitrary value) ``` -------------------------------- ### Add Support for Read-Only Transactions via :read-only? Source: https://github.com/clojure/java.jdbc/blob/master/README.md Support has been added for specifying read-only transactions using the `:read-only?` option, allowing for explicit control over transaction behavior. ```APIDOC // Transaction options now include :read-only? // Example usage: // (with-transaction [t-con db-spec {:read-only? true}] // ...) ``` -------------------------------- ### Fix insert! Syntax Exception in Clojure java.jdbc 0.5.7 Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `(insert! db table [:col] ["val"] {})` syntax, introduced in 0.5.6, previously threw an exception which has been fixed in version 0.5.7. ```APIDOC insert!(db, table, columns: vector, values: vector, options: map) // Fix for syntax: (insert! db table [:col] ["val"] {}) ``` -------------------------------- ### Introduce `ISQLValue` Protocol for Custom SQL Types Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `ISQLValue` protocol has been added to facilitate easier support for custom SQL types when used as parameters in SQL statements, allowing developers to define how custom objects are converted to SQL values. ```APIDOC ISQLValue Purpose: Protocol for converting custom Clojure types to SQL values. Usage: Extend ISQLValue to custom types to define their SQL representation. ``` -------------------------------- ### Add `:timeout` Argument to `prepare-statement` Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md A new `:timeout` argument has been added to the `prepare-statement` function, allowing users to specify a statement timeout in seconds, preventing long-running queries. ```APIDOC prepare-statement Parameter: :timeout (integer) - Specifies the statement timeout in seconds. ``` -------------------------------- ### get-connection Return Type Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `get-connection` function now explicitly declares its return type as `java.sql.Connection`, improving type clarity. ```APIDOC get-connection (db-spec) Returns: java.sql.Connection ``` -------------------------------- ### Clojure java.jdbc: Internal Validation and Error Fixes Source: https://github.com/clojure/java.jdbc/blob/master/README.md The library now includes improved internal validation to ensure SQL and parameters are vectors prior to destructuring, addressing interop edge cases. Additionally, a typo in the `insert-multi!` argument validation exception has been fixed for clearer error messages. ```APIDOC // Internal: Ensures SQL and parameters are vectors for destructuring. // insert-multi! argument validation exception messages improved. ``` -------------------------------- ### Clojure java.jdbc: Removal of Deprecated Functionality Source: https://github.com/clojure/java.jdbc/blob/master/README.md All previously deprecated functionality, including `db-transaction` and the `java.jdbc.deprecated` namespace, has been removed in release 0.6.0. Users are advised to use version 0.5.8 as a bridge to identify and update any code relying on these removed APIs. ```APIDOC Removed Functions: db-transaction Removed Namespaces: java.jdbc.deprecated Migration Note: Use version 0.5.8 to identify deprecated API calls. ``` -------------------------------- ### IResultSetReadColumn Protocol Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `IResultSetReadColumn` protocol is added as an extension point for custom read conversions of `ResultSet` columns. ```APIDOC Protocol: IResultSetReadColumn Purpose: Extension point for custom ResultSet column read conversions. ``` -------------------------------- ### DataSource Connection User Alias Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Introduces `:user` as an alias for `:username` when configuring DataSource connections, providing alternative parameter naming. ```APIDOC DataSource Connection Parameters: :username (or :user) - User for the database connection. ``` -------------------------------- ### query Function Lazy Result Fetching Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `query` function now supports lazy result fetching via the `as-arrays?` option, optimizing performance for large datasets. ```APIDOC query (db-spec sql-params & options) Options: :as-arrays? - Enables lazy result fetching. ``` -------------------------------- ### db-do-* Functions Optional transaction? Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `transaction?` boolean argument in various `db-do-*` functions is now optional, simplifying their invocation. ```APIDOC db-do-* Functions: transaction? parameter: Now optional. ``` -------------------------------- ### Support Read-Only Transactions via `:read-only?` Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Support has been added for specifying read-only transactions using the `:read-only?` option within database specifications, enabling better control over database access permissions. ```APIDOC db-spec Option: :read-only? (boolean) - true: Establishes a read-only connection/transaction. - false: Establishes a read-write connection/transaction. ``` -------------------------------- ### Allow Omitting transaction? in db-do-prepared with PreparedStatement Source: https://github.com/clojure/java.jdbc/blob/master/README.md The `transaction?` argument can now be omitted in `db-do-prepared` when a `PreparedStatement` is passed as the second argument, simplifying calls when a prepared statement is directly provided. ```APIDOC db-do-prepared(db-spec, prepared-statement: PreparedStatement, sql-params: vector, [options: map]) // The 'transaction?' argument can now be omitted when a PreparedStatement is passed as the second argument. ``` -------------------------------- ### db-query-with-resultset Function Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Introduces `db-query-with-resultset` to replace the private `db-with-query-results*`, allowing direct processing of raw `java.sql.ResultSet` objects. ```APIDOC db-query-with-resultset (db-spec sql-params & options) Replaces: db-with-query-results* Purpose: Processes a raw java.sql.ResultSet object. ``` -------------------------------- ### Clojure java.jdbc: Insert Functions Default Transaction Behavior Source: https://github.com/clojure/java.jdbc/blob/master/README.md In release 0.6.1, `insert!` and `insert-multi!` now default the `:transaction?` option to `true`. This ensures that insert operations are performed within a transaction by default, improving data integrity. ```APIDOC insert!(table: string, row: map, options: map) insert-multi!(table: string, rows: seq, options: map) Options: :transaction? (boolean): Defaults to true. If true, the operation is wrapped in a transaction. ``` -------------------------------- ### Omit `transaction?` in `db-do-prepared` with PreparedStatement Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `transaction?` argument for `db-do-prepared` can now be omitted when a `PreparedStatement` is passed as the second argument, simplifying its usage in scenarios where transaction management is handled externally or implicitly. ```APIDOC db-do-prepared Signature 1: (db-do-prepared db-spec sql-statement & params) Signature 2: (db-do-prepared db-spec prepared-statement & params) - transaction?: Optional when prepared-statement is provided. ``` -------------------------------- ### with-db-transaction Isolation Option Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md Adds support for specifying transaction isolation levels using the `:isolation` option within the `with-db-transaction` function. ```APIDOC with-db-transaction (db-spec & options) Options: :isolation - Specifies the transaction isolation level. ``` -------------------------------- ### db-spec Parameter Override Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `:set-parameters` option in `db-spec` allows overriding the internal parameter setting function for custom handling of SQL parameter values, such as `NULL` for specific databases. ```APIDOC db-spec (db-spec-map) Options: :set-parameters - Function to override internal parameter setting. ``` -------------------------------- ### Enforce Vector Type for SQL and Parameters Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md To address interop edge cases from other languages, the library now ensures that SQL and parameters are explicitly vectors prior to destructuring, improving robustness. ```APIDOC SQL/Parameters: validation: "Ensured to be vectors prior to destructuring to prevent interop edge cases." ``` -------------------------------- ### Deprecate `db-transaction` in Favor of `with-db-transaction` Source: https://github.com/clojure/java.jdbc/blob/master/CHANGES.md The `db-transaction` function has been deprecated in favor of the `with-db-transaction` macro. The macro provides a more idiomatic and safer way to manage database transactions, ensuring proper resource cleanup. ```APIDOC db-transaction (DEPRECATED) Use: with-db-transaction with-db-transaction Purpose: Macro for managing database transactions. Usage: (with-db-transaction [tx db-spec] ...) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.