-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Added a new JDBC driver parameter - 'TimeZoneID' #7252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| import java.net.URISyntaxException; | ||
| import java.sql.SQLException; | ||
| import java.time.Duration; | ||
| import java.util.Arrays; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
@@ -84,6 +85,7 @@ | |
| import static io.trino.jdbc.ConnectionProperties.SslVerificationMode.CA; | ||
| import static io.trino.jdbc.ConnectionProperties.SslVerificationMode.FULL; | ||
| import static io.trino.jdbc.ConnectionProperties.SslVerificationMode.NONE; | ||
| import static io.trino.jdbc.ConnectionProperties.TIMEZONE_ID; | ||
| import static io.trino.jdbc.ConnectionProperties.TRACE_TOKEN; | ||
| import static io.trino.jdbc.ConnectionProperties.USER; | ||
| import static java.lang.String.format; | ||
|
|
@@ -193,6 +195,21 @@ public Properties getProperties() | |
| return properties; | ||
| } | ||
|
|
||
| public Optional<String> getTimeZoneID() | ||
| throws SQLException | ||
| { | ||
| Optional<String> tzId = TIMEZONE_ID.getValue(properties); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid abbreviations, call it just |
||
|
|
||
| if (tzId.isPresent()) { | ||
| List<String> ids = Arrays.asList(java.util.TimeZone.getAvailableIDs()); | ||
| if (ids.contains(tzId.get())) { | ||
| return tzId; | ||
| } | ||
| throw new SQLException("Specified TimeZoneID is not supported"); | ||
|
Comment on lines
+204
to
+208
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use if (timezone.isPresent()) {
try {
return ZoneId.of(timezone.get());
}
catch (DateTimeException | ZoneRulesException e) {
throw new SQLException("Specified timezone is not supported: " + timezone.get(), e);
}
}
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we don't need to return Optional at all, since we can return |
||
| } | ||
| return tzId; | ||
| } | ||
|
|
||
| public Map<String, String> getExtraCredentials() | ||
| throws SQLException | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Timezone" to be consistent with CLI's
--timezoneThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it lowercase
timezoneto be consistent with other properties (all are lowercase except Kerberos and SSL)