Skip to content
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

feat: adds time zone setting for JDBC #988

Merged
merged 4 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/nightly/en/greptimecloud/integrations/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Use following connect string for your JDBC client.
jdbc:mysql://<host>:4002/<dbname>?user=<username>&password=<password>
```

Read the [time zone setting](/user-guide/client-libraries/java#time-zone) for JDBC.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Read the [time zone setting](/user-guide/client-libraries/java#time-zone) for JDBC.
Read the [time zone setting](https://docs.greptime.com/user-guide/client-libraries/java#time-zone) for JDBC.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to pin the latest version here? I suppose the same version should work?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These documents are displayed at https://greptime.cloud, so the internal links will not work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.


And if you are using client like Python, use following url to connect to your
instance.

Expand Down
11 changes: 11 additions & 0 deletions docs/nightly/en/user-guide/client-libraries/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,17 @@ db.password=

Or you can just get the file from [here](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/ingester-example/src/main/resources/db-connection.properties).

#### Time zone

Set the JDBC time zone by setting URL parameters:

```txt
jdbc:mysql://127.0.0.1:4002?connectionTimeZone=Asia/Shanghai&forceConnectionTimeZoneToSession=true
```

* `connectionTimeZone={LOCAL|SERVER|user-defined-time-zone}` specifies the connection time zone.
* `forceConnectionTimeZoneToSession=true` makes the session `time_zone` variable to be set to the value specified in `connectionTimeZone`.

%}

{template query-library-raw-sql%
Expand Down
2 changes: 2 additions & 0 deletions docs/nightly/zh/greptimecloud/integrations/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ mysql --ssl -u <username> -p -h <host> -P 4002 -A <dbname>
jdbc:mysql://<host>:4002/<dbname>?user=<username>&password=<password>
```

JDBC 的时区设置请阅读[这篇文档](/user-guide/client-libraries/java#时区)。
nicecui marked this conversation as resolved.
Show resolved Hide resolved

如果你使用 Python 等语言的客户端,也可以复制以下 URL 进行连接

```
Expand Down
10 changes: 10 additions & 0 deletions docs/nightly/zh/user-guide/client-libraries/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ db.password=

或者你可以从[这里](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/ingester-example/src/main/resources/db-connection.properties)获取文件。

#### 时区

通过设置 URL 参数来设置 JDBC 时区:

```txt
jdbc:mysql://127.0.0.1:4002?connectionTimeZone=Asia/Shanghai&forceConnectionTimeZoneToSession=true
```

* `connectionTimeZone={LOCAL|SERVER|user-defined-time-zone}` 配置连接时区。
* `forceConnectionTimeZoneToSession=true` 使 session `time_zone` 变量被设置为 `connectionTimeZone` 指定的值。
%}

{template query-library-raw-sql%
Expand Down
2 changes: 2 additions & 0 deletions docs/v0.8/en/greptimecloud/integrations/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Use following connect string for your JDBC client.
jdbc:mysql://<host>:4002/<dbname>?user=<username>&password=<password>
```

Read the [time zone setting](/user-guide/client-libraries/java#time-zone) for JDBC.
nicecui marked this conversation as resolved.
Show resolved Hide resolved

And if you are using client like Python, use following url to connect to your
instance.

Expand Down
11 changes: 11 additions & 0 deletions docs/v0.8/en/user-guide/client-libraries/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,17 @@ db.password=

Or you can just get the file from [here](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/ingester-example/src/main/resources/db-connection.properties).

#### Time zone

Set the JDBC time zone by setting URL parameters:

```txt
jdbc:mysql://127.0.0.1:4002?connectionTimeZone=Asia/Shanghai&forceConnectionTimeZoneToSession=true
```

* `connectionTimeZone={LOCAL|SERVER|user-defined-time-zone}` specifies the connection time zone.
* `forceConnectionTimeZoneToSession=true` makes the session `time_zone` variable to be set to the value specified in `connectionTimeZone`.

%}

{template query-library-raw-sql%
Expand Down
2 changes: 2 additions & 0 deletions docs/v0.8/zh/greptimecloud/integrations/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ mysql --ssl -u <username> -p -h <host> -P 4002 -A <dbname>
jdbc:mysql://<host>:4002/<dbname>?user=<username>&password=<password>
```

JDBC 的时区设置请阅读[这篇文档](/user-guide/client-libraries/java#时区)。
nicecui marked this conversation as resolved.
Show resolved Hide resolved

如果你使用 Python 等语言的客户端,也可以复制以下 URL 进行连接

```
Expand Down
10 changes: 10 additions & 0 deletions docs/v0.8/zh/user-guide/client-libraries/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ db.password=

或者你可以从[这里](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/ingester-example/src/main/resources/db-connection.properties)获取文件。

#### 时区

通过设置 URL 参数来设置 JDBC 时区:

```txt
jdbc:mysql://127.0.0.1:4002?connectionTimeZone=Asia/Shanghai&forceConnectionTimeZoneToSession=true
```

* `connectionTimeZone={LOCAL|SERVER|user-defined-time-zone}` 配置连接时区。
* `forceConnectionTimeZoneToSession=true` 使 session `time_zone` 变量被设置为 `connectionTimeZone` 指定的值。
%}

{template query-library-raw-sql%
Expand Down