Elffuss BraidHub

kikocis/EDC public

main · 1.6 KiBRenderedRawPermalink
1# SQL Common
2
3## Components
4
5### SQL Query Executor
6
7The SQL Library comes with an `SqlQueryExecutor`, that may be used to execute queries on a
8database `java.sql.Connection`.
9
10### Connection Pool
11
12The SQL library defines an `ConnectionPool` interface. The connection pool creates and manages multiple instances of
13a `java.sql.Connection`. This interface may be implemented by other EDC libraries and is one way to retrieve
14a `java.sql.Connection`.
15
16### Connection Factory
17
18The SQL library defines an `ConnectionFactory` interface. The connection factory creates a `java.sql.Connection` for a
19certain kind of database (e.g. PostgreSQL). This interface and may be implemented by other EDC libraries and is one way
20to retrieve a `java.sql.Connection`.
21
22### ConnectionFactoryDataSource
23
24Constructs a `java.sql.DataSource` from a given `ConnectionFactory` to be registered at
25the `org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry`.
26
27### ConnectionPoolDataSource
28
29Constructs a `java.sql.DataSource` from a given `ConnectionPool` to be registered at
30the `org.eclipse.edc.transaction.datasource.spi.DataSourceRegistry`.
31
32## Usage
33
34### 1. Get a `java.sql.Connection`
35
36The connection may be created by any arbitrary java library or by another EDC library, that implements
37the `ConnectionPool` or `ConnectionFactory`.
38
39### 2. Call the `SqlQueryExecutor`
40
41The `SqlQueryExecutor` may be called with a `java.sql.Connection`, the query itself and optional query parameters.
42
43Please note that the `SqlQueryExecutor` does not manage the `java.sql.Connection` itself. This must be done by the
44caller.