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