Skip to content

Commit

Permalink
Document the use of USE_WITH_TIMEZONE
Browse files Browse the repository at this point in the history
  • Loading branch information
davecramer committed Apr 25, 2024
1 parent 953b3d4 commit 34633bc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Note that the most detailed log levels, "`FINEST`", may include sensitive inform
In addition to the standard connection parameters the driver supports a number of additional properties which can be used to specify additional driver behaviour specific to PostgreSQL™. These properties may be specified in either the connection URL or an additional Properties object parameter to DriverManager.getConnection.

| Property | Type | Default | Description |
|-------------------------------| -- |:-----------------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|-------------------------------| |:-----------------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| user | String | null | The database user on whose behalf the connection is being made. |
| password | String | null | The database user's password. |
| options | String | null | Specify 'options' connection initialization parameter. |
Expand Down Expand Up @@ -123,7 +123,7 @@ In addition to the standard connection parameters the driver supports a number o
| sslResponseTimeout | Integer | 5000 | Socket timeout in milliseconds waiting for a response from a request for SSL upgrade from the server. |
| tcpKeepAlive | Boolean | false | Enable or disable TCP keep-alive. |
| tcpNoDelay | Boolean | true | Enable or disable TCP no delay. |
| ApplicationName | String | PostgreSQL JDBC Driver | The application name (require server version >= 9.0). If assumeMinServerVersion is set to >= 9.0 this will be sent in the startup packets, otherwise after the connection is made |
| ApplicationName | String | PostgreSQL JDBC Driver | The application name (require server version >= 9.0). If assumeMinServerVersion is set to >= 9.0 this will be sent in the startup packets, otherwise after the connection is made |
| readOnly | Boolean | false | Puts this connection in read-only mode |
| readOnlyMode | String | transaction | Specifies the behavior when a connection is set to be read only, possible values: ignore, transaction, always |
| disableColumnSanitiser | Boolean | false | Enable optimization that disables column name sanitiser |
Expand Down Expand Up @@ -152,6 +152,7 @@ In addition to the standard connection parameters the driver supports a number o
| authenticationPluginClassName | String | null | Fully qualified class name of the class implementing the AuthenticationPlugin interface. If this is null, the password value in the connection properties will be used. |
| unknownLength | Integer | Integer.MAX_LENGTH | Specifies the length to return for types of unknown length |
| stringtype | String | null | Specify the type to use when binding `PreparedStatement` parameters set via `setString()` |
| useWithTimezone | Boolean | false | Map time with timezone and timestamp with timezone to `TIME_WITH_TIMEZONE` and `TIMESTAMP_WITH_TIMEZONE` |

#### System Properties
| Property | Type | Default | Description |
Expand Down
3 changes: 3 additions & 0 deletions docs/content/documentation/use.md
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ If we quote them, then we end up sending ""colname"" to the backend instead of "
Fully qualified class name of the class implementing the AuthenticationPlugin interface. If this is null, the password
value in the connection properties will be used.

* **`useWithTimezone (`*boolean*`)`** *Default `false`*\
Map time with timezone and timestamp with timezone to `TIME_WITH_TIMEZONE` and `TIMESTAMP_WITH_TIMEZONE`

### Unix sockets

By adding junixsocket you can obtain a socket factory that works with the driver.
Expand Down
9 changes: 5 additions & 4 deletions pgjdbc/src/main/java/org/postgresql/PGProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,14 @@ public enum PGProperty {
"The timeout value in seconds max(2147484) used for socket read operations."),

/**
* Enable or disable mapping of PG types with TIMEZONE into SQL types with TIMEZONE.
* Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE}

Check failure on line 604 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Code style

[Task :postgresql:javadoc] reference not found * Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE} ^

Check failure on line 604 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 8, liberica, PG 13, extendedCacheEverything, no_scram, no_ssl, ubuntu, server_tz UTC, client_tz UTC, fr_FR, no_gss, replication, no_slow_tests

[Task :postgresql:javadoc] reference not found * Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE} ^

Check failure on line 604 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 11, temurin, PG 13, extendedForPrepared, no_scram, no_ssl, ubuntu, server_tz America/New_York, client_tz Pacific/Chatham, fr_FR, no_gss, no_replication, no_slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE} ^

Check failure on line 604 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 17, liberica, PG 8.4, no_scram, no_ssl, ubuntu, server_tz Pacific/Chatham, client_tz UTC, fr_FR, gss, no_replication, slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE} ^

Check failure on line 604 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 21, oracle, PG 14, no_scram, no_ssl, ubuntu, server_tz America/New_York, client_tz UTC, ru_RU, no_gss, no_replication, no_slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE} ^

Check failure on line 604 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 21, zulu, PG 12, scram, no_ssl, same hashcode, ubuntu, server_tz Pacific/Chatham, client_tz America/New_York, tr_TR, no_gss, no_replication, no_slow_tests

[Task :postgresql:javadoc] reference not found * Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE} ^

Check failure on line 604 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 22, oracle, PG 11, simple query, scram, ssl, ubuntu, server_tz America/New_York, client_tz Pacific/Chatham, fr_FR, no_gss, no_replication, no_slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * Enable mapping of `WITH TIMEZONE` to {@link java.sql.Types.TIME_WITH_TIMEZONE} ^
* and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} .

Check failure on line 605 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Code style

[Task :postgresql:javadoc] reference not found * and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} . ^

Check failure on line 605 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 8, liberica, PG 13, extendedCacheEverything, no_scram, no_ssl, ubuntu, server_tz UTC, client_tz UTC, fr_FR, no_gss, replication, no_slow_tests

[Task :postgresql:javadoc] reference not found * and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} . ^

Check failure on line 605 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 11, temurin, PG 13, extendedForPrepared, no_scram, no_ssl, ubuntu, server_tz America/New_York, client_tz Pacific/Chatham, fr_FR, no_gss, no_replication, no_slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} . ^

Check failure on line 605 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 17, liberica, PG 8.4, no_scram, no_ssl, ubuntu, server_tz Pacific/Chatham, client_tz UTC, fr_FR, gss, no_replication, slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} . ^

Check failure on line 605 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 21, oracle, PG 14, no_scram, no_ssl, ubuntu, server_tz America/New_York, client_tz UTC, ru_RU, no_gss, no_replication, no_slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} . ^

Check failure on line 605 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 21, zulu, PG 12, scram, no_ssl, same hashcode, ubuntu, server_tz Pacific/Chatham, client_tz America/New_York, tr_TR, no_gss, no_replication, no_slow_tests

[Task :postgresql:javadoc] reference not found * and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} . ^

Check failure on line 605 in pgjdbc/src/main/java/org/postgresql/PGProperty.java

View workflow job for this annotation

GitHub Actions / Java 22, oracle, PG 11, simple query, scram, ssl, ubuntu, server_tz America/New_York, client_tz Pacific/Chatham, fr_FR, no_gss, no_replication, no_slow_tests, stress JIT

[Task :postgresql:javadoc] reference not found * and {@link java.sql.Types.TIMESTAMP_WITH_TIMEZONE} . ^
* The default is {@code false}
*/
SQL_TYPES_WITH_TIMEZONE(
"sqlTypesWithTimezone",
USE_WITH_TIMEZONE(
"useWithTimezone",
"false",
"Enable or disable mapping of PG types with TIMEZONE into SQL types with TIMEZONE."
"Map time with timezone and timestamp with timezone to (@code TIME_WITH_TIMEZONE) and (@code TIMESTAMP_WITH_TIMEZONE)"
+ "The default is (@code false)"),

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,18 +593,18 @@ public int getSocketTimeout() {

/**
* @param enabled if PG types with TIMEZONE should map into SQL types with TIMEZONE
* @see PGProperty#SQL_TYPES_WITH_TIMEZONE
* @see PGProperty#USE_WITH_TIMEZONE
*/
public void setSqlTypesWithTimezone(boolean enabled) {
PGProperty.SQL_TYPES_WITH_TIMEZONE.set(properties, enabled);
PGProperty.USE_WITH_TIMEZONE.set(properties, enabled);
}

/**
* @return true if SQL types with TIMEZONE is enabled
* @see PGProperty#SQL_TYPES_WITH_TIMEZONE
* @see PGProperty#USE_WITH_TIMEZONE
*/
public boolean getSqlTypesWithTimezone() {
return PGProperty.SQL_TYPES_WITH_TIMEZONE.getBoolean(properties);
return PGProperty.USE_WITH_TIMEZONE.getBoolean(properties);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pgjdbc/src/main/java/org/postgresql/jdbc/PgConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public PgConnection(HostSpec[] hostSpecs,
rollbackQuery = createQuery("ROLLBACK", false, true).query;

int unknownLength = PGProperty.UNKNOWN_LENGTH.getInt(info);
boolean sqlTypesWithTimezone = PGProperty.SQL_TYPES_WITH_TIMEZONE.getBoolean(info);
boolean sqlTypesWithTimezone = PGProperty.USE_WITH_TIMEZONE.getBoolean(info);

// Initialize object handling
@SuppressWarnings("argument")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class DatabaseMetaDataTest {
public void initDatabaseMetaDataTest(BinaryMode binaryMode, boolean sqlTypesWithTimezone) throws SQLException {
final Properties props = new Properties();
if (sqlTypesWithTimezone) {
PGProperty.SQL_TYPES_WITH_TIMEZONE.set(props, true);
PGProperty.USE_WITH_TIMEZONE.set(props, true);
}
if (binaryMode == BinaryMode.FORCE) {
PGProperty.PREPARE_THRESHOLD.set(props, -1);
Expand Down

0 comments on commit 34633bc

Please sign in to comment.