You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/using-the-jdbc-wrapper/DataSource.md
+11-13Lines changed: 11 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,20 @@
1
1
# Connecting with a DataSource
2
-
In addition to the `DriverManager` class, one can also use a datasource to establish new connections.
3
-
The JDBC Wrapper has a built-in datasource class called [AwsWrapperDataSource](../../wrapper/src/main/java/com/amazon/awslabs/jdbc/ds/AwsWrapperDataSource.java).
4
-
The `AwsWrapperDataSource` enables the JDBC Wrapper to work with various driver-specific datasources.
2
+
You can use the `DriverManager` class or a datasource to establish a new connection when using the JDBC Wrapper. The JDBC Wrapper has a built-in datasource class named [AwsWrapperDataSource](../../wrapper/src/main/java/com/amazon/awslabs/jdbc/ds/AwsWrapperDataSource.java) that allows the JDBC Wrapper to work with various driver-specific datasources.
5
3
6
4
## Using the AwsWrapperDataSource
7
5
8
-
There are 3 tasks to establish a connection with the AwsWrapperDataSource:
6
+
To establish a connection with the AwsWrapperDataSource, you must:
9
7
10
8
1. Configure the property names for the underlying driver-specific datasource.
11
-
2. Target driver-specific datasource.
9
+
2. Target a driver-specific datasource.
12
10
3. Configure the driver-specific datasource.
13
11
14
12
### Configurable DataSource Properties
15
13
16
14
To allow the AWS Advanced JDBC Wrapper to work with multiple driver-specific datasources,
17
-
it is necessary for the user to specify what property names the underlying datasource uses.
15
+
you need to specify what property names the underlying datasource uses.
18
16
For example, one datasource implementation could use the method `setUser` to set the datasource username,
19
-
and another could use the method `setUsername` to do the same.
20
-
See the table below for a list of configurable property names.
17
+
while another might use the method `setUsername` for the same task. See the table below for a list of configurable property names.
21
18
22
19
> **:warning: Note:** If the same connection property is provided both explicitly in the connection URL and in the datasource properties, the value set in the connection URL will take precedence.
23
20
@@ -35,17 +32,18 @@ See the table below for a list of configurable property names.
35
32
36
33
## Using the AwsWrapperDataSource with Connection Pooling Frameworks
37
34
38
-
The JDBC Wrapper also supports establishing connection with a connection pooling framework.
35
+
The JDBC Wrapper also supports establishing a connection with a connection pooling framework.
39
36
40
-
There are 4 tasks to use the JDBC Wrapper with a connection pool:
37
+
To use the JDBC Wrapper with a connection pool, you must:
41
38
42
39
1. Configure the connection pool.
43
40
2. Set the datasource class name to `com.amazon.awslabs.jdbc.ds.AwsWrapperDataSource` for the connection pool.
44
41
3. Configure the `AwsWrapperDataSource`.
45
42
4. Configure the driver-specific datasource.
46
43
47
-
### HikariCP
48
-
[HikariCP](https://github.com/brettwooldridge/HikariCP) is a popular connection pool, below are the steps to a simple connection pool with HikariCP and PostgreSQL:
44
+
### HikariCP Pooling Example
45
+
46
+
[HikariCP](https://github.com/brettwooldridge/HikariCP) is a popular connection pool; the steps that follow configure a simple connection pool with HikariCP and PostgreSQL:
49
47
50
48
1. Configure the HikariCP datasource:
51
49
```java
@@ -87,4 +85,4 @@ There are 4 tasks to use the JDBC Wrapper with a connection pool:
87
85
88
86
See [here](./sample-code/HikariSample.java) for a complete sample.
89
87
90
-
> **:warning:Note:** HikariCP supports either DataSource-based configuration or DriverManager-based configuration by specifying the `dataSourceClassName` or the `jdbcUrl`. When using the `AwsWrapperDataSource`one must specify the `dataSourceClassName`, therefore `HikariDataSource.setJdbcUrl` is not supported. For more information see HikariCP's [documentation](https://github.com/brettwooldridge/HikariCP#gear-configuration-knobs-baby).
88
+
> **:warning:Note:** HikariCP supports either DataSource-based configuration or DriverManager-based configuration by specifying the `dataSourceClassName` or the `jdbcUrl`. When using the `AwsWrapperDataSource`you must specify the `dataSourceClassName`, therefore `HikariDataSource.setJdbcUrl` is not supported. For more information see HikariCP's [documentation](https://github.com/brettwooldridge/HikariCP#gear-configuration-knobs-baby).
0 commit comments