Skip to content

Commit

Permalink
feat: adds time zone setting for JDBC (#988)
Browse files Browse the repository at this point in the history
Co-authored-by: Yiran <[email protected]>
  • Loading branch information
killme2008 and nicecui authored May 29, 2024
1 parent 3cf0f0e commit 26461eb
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 0 deletions.
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](https://docs.greptime.com/user-guide/client-libraries/java#time-zone) for JDBC.

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 的时区设置请阅读[这篇文档](https://docs.greptime.cn/user-guide/client-libraries/java#时区)

如果你使用 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](https://docs.greptime.com/user-guide/client-libraries/java#time-zone) for JDBC.

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 的时区设置请阅读[这篇文档](https://docs.greptime.cn/user-guide/client-libraries/java#时区)

如果你使用 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

0 comments on commit 26461eb

Please sign in to comment.