Skip to content

Commit 2cab55a

Browse files
committed
Update links to JDBC documentation
The link we used for connection parameters and URIs was broken, 404.
1 parent 5a893b1 commit 2cab55a

File tree

5 files changed

+48
-32
lines changed

5 files changed

+48
-32
lines changed

docs/content/architecture/user-management.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ When you create a Postgres cluster with PGO and do not specify any additional us
2020
- `user`: The name of the user account.
2121
- `password`: The password for the user account.
2222
- `dbname`: The name of the database that the user has access to by default.
23-
- `host`: The name of the host of the database. This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the primary Postgres instance.
23+
- `host`: The name of the host of the database.
24+
This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the primary Postgres instance.
2425
- `port`: The port that the database is listening on.
25-
- `uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) that provides all the information for logging into the Postgres database.
26-
- `jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/head/connect.html) that provides all the information for logging into the Postgres database via the JDBC driver.
26+
- `uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
27+
that provides all the information for logging into the Postgres database.
28+
- `jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/use/)
29+
that provides all the information for logging into the Postgres database via the JDBC driver.
2730

2831
You can see this default behavior in the [connect to a cluster]({{< relref "tutorial/connect-cluster.md" >}}) portion of the tutorial.
2932

docs/content/quickstart/_index.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,23 @@ Within this Secret are attributes that provide information to let you log into t
7878
- `user`: The name of the user account.
7979
- `password`: The password for the user account.
8080
- `dbname`: The name of the database that the user has access to by default.
81-
- `host`: The name of the host of the database. This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the primary Postgres instance.
81+
- `host`: The name of the host of the database.
82+
This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the primary Postgres instance.
8283
- `port`: The port that the database is listening on.
83-
- `uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) that provides all the information for logging into the Postgres database.
84-
- `jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/head/connect.html) that provides all the information for logging into the Postgres database via the JDBC driver.
84+
- `uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
85+
that provides all the information for logging into the Postgres database.
86+
- `jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/use/)
87+
that provides all the information for logging into the Postgres database via the JDBC driver.
8588

8689
If you deploy your Postgres cluster with the [PgBouncer](https://www.pgbouncer.org/) connection pooler, there are additional values that are populated in the user Secret, including:
8790

88-
- `pgbouncer-host`: The name of the host of the PgBouncer connection pooler. This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the PgBouncer connection pooler.
91+
- `pgbouncer-host`: The name of the host of the PgBouncer connection pooler.
92+
This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the PgBouncer connection pooler.
8993
- `pgbouncer-port`: The port that the PgBouncer connection pooler is listening on.
90-
- `pgbouncer-uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) that provides all the information for logging into the Postgres database via the PgBouncer connection pooler.
91-
- `pgbouncer-jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/head/connect.html) that provides all the information for logging into the Postgres database via the PgBouncer connection pooler using the JDBC driver.
94+
- `pgbouncer-uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
95+
that provides all the information for logging into the Postgres database via the PgBouncer connection pooler.
96+
- `pgbouncer-jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/use/)
97+
that provides all the information for logging into the Postgres database via the PgBouncer connection pooler using the JDBC driver.
9298

9399
Note that **all connections use TLS**. PGO sets up a PKI for your Postgres clusters. You can also choose to bring your own PKI / certificate authority; this is covered later in the documentation.
94100

docs/content/tutorial/connect-cluster.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ When your Postgres cluster is initialized, PGO will bootstrap a database and Pos
3333
- `user`: The name of the user account.
3434
- `password`: The password for the user account.
3535
- `dbname`: The name of the database that the user has access to by default.
36-
- `host`: The name of the host of the database. This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the primary Postgres instance.
36+
- `host`: The name of the host of the database.
37+
This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the primary Postgres instance.
3738
- `port`: The port that the database is listening on.
38-
- `uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) that provides all the information for logging into the Postgres database.
39-
- `jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/head/connect.html) that provides all the information for logging into the Postgres database via the JDBC driver.
39+
- `uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
40+
that provides all the information for logging into the Postgres database.
41+
- `jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/use/) that provides
42+
all the information for logging into the Postgres database via the JDBC driver.
4043

4144
All connections are over TLS. PGO provides its own certificate authority (CA) to allow you to securely connect your applications to your Postgres clusters. This allows you to use the [`verify-full` "SSL mode"](https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS) of Postgres, which provides eavesdropping protection and prevents MITM attacks. You can also choose to bring your own CA, which is described later in this tutorial in the [Customize Cluster]({{< relref "./customize-cluster.md" >}}) section.
4245

docs/content/tutorial/connection-pooling.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ kubectl -n postgres-operator describe secrets keycloakdb-pguser-keycloakdb
4545

4646
You should see that there are several new attributes included in this Secret that allow for you to connect to your Postgres instance via the connection pooler:
4747

48-
- `pgbouncer-host`: The name of the host of the PgBouncer connection pooler. This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the PgBouncer connection pooler.
48+
- `pgbouncer-host`: The name of the host of the PgBouncer connection pooler.
49+
This references the [Service](https://kubernetes.io/docs/concepts/services-networking/service/) of the PgBouncer connection pooler.
4950
- `pgbouncer-port`: The port that the PgBouncer connection pooler is listening on.
50-
- `pgbouncer-uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING) that provides all the information for logging into the Postgres database via the PgBouncer connection pooler.
51-
- `pgbouncer-jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/head/connect.html) that provides all the information for logging into the Postgres database via the PgBouncer connection pooler using the JDBC driver. Note that by default, the connection string disable JDBC managing prepared transactions for [optimal use with PgBouncer](https://www.pgbouncer.org/faq.html#how-to-use-prepared-statements-with-transaction-pooling).
51+
- `pgbouncer-uri`: A [PostgreSQL connection URI](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
52+
that provides all the information for logging into the Postgres database via the PgBouncer connection pooler.
53+
- `pgbouncer-jdbc-uri`: A [PostgreSQL JDBC connection URI](https://jdbc.postgresql.org/documentation/use/) that provides
54+
all the information for logging into the Postgres database via the PgBouncer connection pooler using the JDBC driver.
55+
Note that by default, the connection string disable JDBC managing prepared transactions for
56+
[optimal use with PgBouncer](https://www.pgbouncer.org/faq.html#how-to-use-prepared-statements-with-transaction-pooling).
5257

5358
Open up the file in `kustomize/keycloak/keycloak.yaml`. Update the `DB_ADDR` and `DB_PORT` values to be the following:
5459

internal/controller/postgrescluster/postgres.go

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,16 @@ func (r *Reconciler) generatePostgresUserSecret(
117117
Path: database,
118118
}).String())
119119

120-
// Reference to the PostgreSQL JDBC URI:
121-
// https://jdbc.postgresql.org/documentation/head/connect.html
122-
jdbc_query := url.Values{}
123-
jdbc_query.Set("user", username)
124-
jdbc_query.Set("password", string(intent.Data["password"]))
120+
// The JDBC driver requires a different URI scheme and query component.
121+
// - https://jdbc.postgresql.org/documentation/use/#connection-parameters
122+
query := url.Values{}
123+
query.Set("user", username)
124+
query.Set("password", string(intent.Data["password"]))
125125
intent.Data["jdbc-uri"] = []byte((&url.URL{
126126
Scheme: "jdbc:postgresql",
127127
Host: net.JoinHostPort(hostname, port),
128128
Path: database,
129-
RawQuery: jdbc_query.Encode(),
129+
RawQuery: query.Encode(),
130130
}).String())
131131
}
132132

@@ -149,21 +149,20 @@ func (r *Reconciler) generatePostgresUserSecret(
149149
Path: database,
150150
}).String())
151151

152-
// Reference to the PostgreSQL JDBC URI:
153-
// https://jdbc.postgresql.org/documentation/head/connect.html
154-
jdbc_query := url.Values{}
155-
jdbc_query.Set("user", username)
156-
jdbc_query.Set("password", string(intent.Data["password"]))
157-
// Prepared statements to be disabled to use transaction pooling. Speaking
158-
// with JDBC maintainers, we can just set this to disabled in general when
159-
// connecting to pgBouncer
160-
// https://www.pgbouncer.org/faq.html#how-to-use-prepared-statements-with-transaction-pooling
161-
jdbc_query.Set("prepareThreshold", "0")
152+
// The JDBC driver requires a different URI scheme and query component.
153+
// Disable prepared statements to be compatible with PgBouncer's
154+
// transaction pooling.
155+
// - https://jdbc.postgresql.org/documentation/use/#connection-parameters
156+
// - https://www.pgbouncer.org/faq.html#how-to-use-prepared-statements-with-transaction-pooling
157+
query := url.Values{}
158+
query.Set("user", username)
159+
query.Set("password", string(intent.Data["password"]))
160+
query.Set("prepareThreshold", "0")
162161
intent.Data["pgbouncer-jdbc-uri"] = []byte((&url.URL{
163162
Scheme: "jdbc:postgresql",
164163
Host: net.JoinHostPort(hostname, port),
165164
Path: database,
166-
RawQuery: jdbc_query.Encode(),
165+
RawQuery: query.Encode(),
167166
}).String())
168167
}
169168
}

0 commit comments

Comments
 (0)