Merge remote-tracking branch 'origin/3.0' into feat/TD-30268
This commit is contained in:
commit
d1013b20f9
|
@ -134,3 +134,4 @@ tags
|
|||
.clangd
|
||||
*CMakeCache*
|
||||
*CMakeFiles*
|
||||
.history/
|
||||
|
|
|
@ -25,7 +25,7 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
type_name [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
|
|
@ -13,7 +13,7 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
type_name [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
|
|
@ -656,6 +656,7 @@ use_current_timezone: {
|
|||
For example, if the time zone configured by the Client is UTC + 0800, TIMETRUNCATE ('2020-01-01 23:00:00', 1d, 0) returns the result of '2020-01-01 08:00:00'.
|
||||
When using TIMETRUNCATE ('2020-01-01 23:00:00', 1d, 1), the result is 2020-01-01 00:00:00 '.
|
||||
When use_current_timezone is not specified, use_current_timezone defaults to 1.
|
||||
- When truncating a time value to the week (1w), weeks are determined using the Unix epoch (1970-01-01T00:00:00Z UTC). The Unix epoch was on a Thursday, so all calculated weeks begin on Thursday.
|
||||
|
||||
#### TIMEZONE
|
||||
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
---
|
||||
toc_max_heading_level: 4
|
||||
title: "View"
|
||||
sidebar_label: "View"
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Starting from TDengine 3.2.1.0, TDengine Enterprise Edition provides view function, which is convenient for users to simplify operation and improve sharing ability among users.
|
||||
|
||||
A view is essentially a query statement stored in a database. The view (non-materialized view) itself does not contain data, and only dynamically executes the query statement specified by the view when reading data from the view. We specify a name when creating a view, and then we can query it like using a regular table. The use of views should follow the following rules:
|
||||
- Views can be defined and used nested, and are bound to the specified or current database when created.
|
||||
- Within the same database, duplicate view names are not allowed, and it is recommended not to have duplicate view names and table names (not mandatory). When the view and table names have the same name, operations such as writing, querying, authorizing, and revoking permissions will prioritize using the same-named table.
|
||||
|
||||
|
||||
|
||||
## Grammar
|
||||
|
||||
### Create (update) view
|
||||
|
||||
```sql
|
||||
CREATE [ OR REPLACE ] VIEW [db_name.]view_name AS query
|
||||
```
|
||||
|
||||
Description:
|
||||
- When creating a view, you can specify the database name ( db_name ) to which the view is bound. If not explicitly specified, it defaults to the database bound to the current connection.
|
||||
- It is recommended to specify the database name in the query statement, support cross-database views, and default to the database bound to the view when not specified (it may not be the database specified by the current connection);
|
||||
|
||||
### View View
|
||||
|
||||
1. View all views under a database
|
||||
|
||||
```sql
|
||||
SHOW [db_name.]VIEWS;
|
||||
```
|
||||
|
||||
2. View the creation statement of the view
|
||||
|
||||
```sql
|
||||
SHOW CREATE VIEW [db_name.]view_name;
|
||||
```
|
||||
|
||||
3. View view column information
|
||||
|
||||
```sql
|
||||
DESCRIBE [db_name.]view_name;
|
||||
```
|
||||
|
||||
4. View all view information
|
||||
|
||||
```sql
|
||||
SELECT ... FROM information_schema.ins_views;
|
||||
```
|
||||
|
||||
### Delete a view
|
||||
|
||||
```sql
|
||||
DROP VIEW [IF EXISTS] [db_name.]view_name;
|
||||
```
|
||||
|
||||
## Permissions
|
||||
|
||||
### Description
|
||||
View permissions are divided into three types: READ, WRITE, and ALTER. Query operations require READ permissions, write operations require WRITE permissions, and delete and modify operations on the view itself require ALTER permissions.
|
||||
|
||||
### Rules
|
||||
- The creator of the view and the root user have all permissions by default.
|
||||
- Authorization and revocation of permissions for other users can be performed through the GRANT and REVOKE statements, which can only be performed by the root user.
|
||||
- View permissions need to be authorized and revoked separately. Authorization and revocation through db. * do not include view permissions.
|
||||
- Views can be defined and used nested, and the verification of view permissions is also performed by recursion.
|
||||
- In order to facilitate the sharing and use of views, the concept of view effective user (i.e. the user who creates the view) is introduced. Authorized users can use the read and write permissions of the view effective user's library, table, and nested view. Note: After the view is REPLACE, the effective user will also be updated.
|
||||
|
||||
The detailed rules for controlling relevant permissions are summarized as follows:
|
||||
|
||||
| Serial number | Operation | Permission requirements |
|
||||
| --- | --- | --- |
|
||||
| 1 | CREATE OR REPLACE VIEW (Create a new view) | The user has WRITE permission on the database to which the view belongs And Users have query permissions for the target library, table, and view of the view. If the object in the query is a view, it must meet rule 8 in the current table. |
|
||||
| 2 | CREATE OR REPLACE VIEW (Overwrite old view) | The user has WRITE permission on the database to which the view belongs, and ALTER permission on the old view And Users have query permissions for the target library, table, and view of the view. If the object in the query is a view, it must meet rule 8 in the current table. |
|
||||
| 3 | DROP VIEW | The user has ALTER permission on the view |
|
||||
| 4 | SHOW VIEWS | No |
|
||||
| 5 | SHOW CREATE VIEW | No |
|
||||
| 6 | DESCRIBE VIEW | No |
|
||||
| 7 | System table query | No |
|
||||
| 8 | SELECT FROM VIEW | The operating user has READ permissions for the view And Operating users or view effective users have READ permissions on the target library, table, and view of the view |
|
||||
| 9 | INSERT INTO VIEW | The operation user has WRITE permission on the view And Operating users or view effective users have WRITE permissions on the target library, table, and view of the view |
|
||||
| 10 | GRANT/REVOKE | Only the root user has permission |
|
||||
|
||||
|
||||
### Grammar
|
||||
|
||||
#### Authorization
|
||||
|
||||
```sql
|
||||
GRANT privileges ON [db_name.]view_name TO user_name
|
||||
privileges: {
|
||||
ALL,
|
||||
| priv_type [, priv_type] ...
|
||||
}
|
||||
priv_type: {
|
||||
READ
|
||||
| WRITE
|
||||
| ALTER
|
||||
}
|
||||
```
|
||||
|
||||
#### Recover permissions
|
||||
|
||||
```sql
|
||||
REVOKE privileges ON [db_name.]view_name FROM user_name
|
||||
privileges: {
|
||||
ALL,
|
||||
| priv_type [, priv_type] ...
|
||||
}
|
||||
priv_type: {
|
||||
READ
|
||||
| WRITE
|
||||
| ALTER
|
||||
}
|
||||
```
|
||||
|
||||
## Usage scenarios
|
||||
|
||||
| SQL query | SQL write | STMT query | STMT write | Subscribe | Stream |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| Support | Not supported yet | Not supported yet | Not supported yet | Support | Not supported yet |
|
||||
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
- Create a view
|
||||
|
||||
```sql
|
||||
CREATE VIEW view1 AS SELECT _wstart, count(*) FROM table1 INTERVAL(1d);
|
||||
CREATE VIEW view2 AS SELECT ts, col2 FROM table1;
|
||||
CREATE VIEW view3 AS SELECT * from view1;
|
||||
```
|
||||
|
||||
- Query data
|
||||
|
||||
```sql
|
||||
SELECT * from view1;
|
||||
```
|
||||
|
||||
- Delete data
|
||||
|
||||
```sql
|
||||
DROP VIEW view1;
|
||||
```
|
|
@ -64,64 +64,20 @@ In the above example code, `taos_connect()` establishes a connection to port 603
|
|||
|
||||
## Sample program
|
||||
|
||||
This section shows sample code for standard access methods to TDengine clusters using the client driver.
|
||||
This section shows sample code for standard access methods to TDengine clusters using the client driver.
|
||||
|
||||
### Synchronous query example
|
||||
- [Synchronous query example](https://github.com/taosdata/TDengine/tree/main/docs/examples/c/demo.c)
|
||||
|
||||
<details>
|
||||
<summary>Synchronous query</summary>
|
||||
- [Asynchronous query example](https://github.com/taosdata/TDengine/tree/main/docs/examples/c/asyncdemo.c)
|
||||
|
||||
```c
|
||||
{{#include examples/c/demo.c}}
|
||||
```
|
||||
- [Parameter binding example](https://github.com/taosdata/TDengine/tree/main/docs/examples/c/prepare.c)
|
||||
|
||||
</details>
|
||||
- [Schemaless writing example](https://github.com/taosdata/TDengine/tree/main/docs/examples/c/schemaless.c)
|
||||
|
||||
### Asynchronous query example
|
||||
|
||||
<details>
|
||||
<summary>Asynchronous queries</summary>
|
||||
|
||||
```c
|
||||
{{#include examples/c/asyncdemo.c}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Parameter binding example
|
||||
|
||||
<details>
|
||||
<summary>Parameter Binding</summary>
|
||||
|
||||
```c
|
||||
{{#include examples/c/prepare.c}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Pattern-free writing example
|
||||
|
||||
<details>
|
||||
<summary>Mode free write</summary>
|
||||
|
||||
```c
|
||||
{{#include examples/c/schemaless.c}}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Subscription and consumption example
|
||||
|
||||
<details>
|
||||
<summary>Subscribe and consume</summary>
|
||||
|
||||
```c
|
||||
```
|
||||
|
||||
</details>
|
||||
- [Subscription and consumption example](https://github.com/taosdata/TDengine/tree/main/docs/examples/c/tmq.c)
|
||||
|
||||
:::info
|
||||
More example code and downloads are available at [GitHub](https://github.com/taosdata/TDengine/tree/develop/examples/c).
|
||||
More example code and downloads are available at [GitHub](https://github.com/taosdata/TDengine/tree/main/docs/examples/c).
|
||||
You can find it in the installation directory under the `examples/c` path. This directory has a makefile and can be compiled under Linux/macOS by executing `make` directly.
|
||||
**Hint:** When compiling in an ARM environment, please remove `-msse4.2` from the makefile. This option is only supported on the x64/x86 hardware platforms.
|
||||
|
||||
|
@ -311,7 +267,7 @@ Starting with versions 2.1.1.0 and 2.1.2.0, TDengine has significantly improved
|
|||
|
||||
Note: If `taos_stmt_execute()` succeeds, you can reuse the parsed result of `taos_stmt_prepare()` to bind new data in steps 3 to 6 if you don't need to change the SQL command. However, if there is an execution error, it is not recommended to continue working in the current context but release the resources and start again with `taos_stmt_init()` steps.
|
||||
|
||||
The specific functions related to the interface are as follows (see also the [prepare.c](https://github.com/taosdata/TDengine/blob/develop/examples/c/prepare.c) file for the way to use the corresponding functions)
|
||||
The specific functions related to the interface are as follows (see also the [prepare.c](https://github.com/taosdata/TDengine/blob/develop/docs/examples/c/prepare.c) file for the way to use the corresponding functions)
|
||||
|
||||
- `TAOS_STMT* taos_stmt_init(TAOS *taos)`
|
||||
|
||||
|
@ -661,4 +617,4 @@ In addition to writing data using the SQL method or the parameter binding API, w
|
|||
- tmq_get_table_name : table name of result, NULL if failed
|
||||
- tmq_get_res_type : result type tmq_res_t
|
||||
- tmq_get_topic_name : topic name of result, NULL if failed
|
||||
- tmq_get_db_name : db name of result, NULL if failed
|
||||
- tmq_get_db_name : db name of result, NULL if failed
|
||||
|
|
|
@ -69,7 +69,7 @@ REST connection supports all platforms that can run Java.
|
|||
After an error is reported, the error message and error code can be obtained through SQLException.
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcBasicDemo.java:jdbc_exception}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/JdbcBasicDemo.java:jdbc_exception}}
|
||||
```
|
||||
|
||||
There are four types of error codes that the JDBC client library can report:
|
||||
|
@ -150,7 +150,7 @@ TDengine currently supports timestamp, number, character, Boolean type, and the
|
|||
Due to historical reasons, the BINARY type data in TDengine is not truly binary data and is no longer recommended for use. Please use VARBINARY type instead.
|
||||
GEOMETRY type is binary data in little endian byte order, which complies with the WKB specification. For detailed information, please refer to [Data Type](../../taos-sql/data-type/)
|
||||
For WKB specifications, please refer to [Well Known Binary (WKB)](https://libgeos.org/specifications/wkb/)
|
||||
For Java connector, the jts library can be used to easily create GEOMETRY type objects, serialize them, and write them to TDengine. Here is an example [Geometry example](https://github.com/taosdata/TDengine/blob/3.0/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/GeometryDemo.java)
|
||||
For Java connector, the jts library can be used to easily create GEOMETRY type objects, serialize them, and write them to TDengine. Here is an example [Geometry example](https://github.com/taosdata/TDengine/blob/main/docs/examples/java/src/main/java/com/taos/example/GeometryDemo.java)
|
||||
|
||||
|
||||
## Installation Steps
|
||||
|
@ -395,7 +395,7 @@ For example, if you specify the password as `taosdata` in the URL and specify th
|
|||
### Create database and tables
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcBasicDemo.java:create_db_and_table}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/JdbcBasicDemo.java:create_db_and_table}}
|
||||
```
|
||||
|
||||
> **Note**: If you do not use `USE power` to specify the database, all subsequent operations on the table need to add the database name as a prefix, such as power.meters.
|
||||
|
@ -403,7 +403,7 @@ For example, if you specify the password as `taosdata` in the URL and specify th
|
|||
### Insert data
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcBasicDemo.java:insert_data}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/JdbcBasicDemo.java:insert_data}}
|
||||
```
|
||||
|
||||
> NOW is an internal function. The default is the current time of the client's computer.
|
||||
|
@ -412,7 +412,7 @@ For example, if you specify the password as `taosdata` in the URL and specify th
|
|||
### Querying data
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcBasicDemo.java:query_data}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/JdbcBasicDemo.java:query_data}}
|
||||
```
|
||||
|
||||
> The query is consistent with operating a relational database. When using subscripts to get the contents of the returned fields, you have to start from 1. However, we recommend using the field names to get the values of the fields in the result set.
|
||||
|
@ -422,7 +422,7 @@ For example, if you specify the password as `taosdata` in the URL and specify th
|
|||
<RequestId />
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JdbcBasicDemo.java:with_reqid}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/JdbcBasicDemo.java:with_reqid}}
|
||||
```
|
||||
|
||||
### Writing data via parameter binding
|
||||
|
@ -440,20 +440,20 @@ TDengine has significantly improved the bind APIs to support data writing (INSER
|
|||
<TabItem value="native" label="native connection">
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ParameterBindingBasicDemo.java:para_bind}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/ParameterBindingBasicDemo.java:para_bind}}
|
||||
```
|
||||
|
||||
This is the [Detailed Example](https://github.com/taosdata/TDengine/blob/main/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ParameterBindingFullDemo.java)
|
||||
This is the [Detailed Example](https://github.com/taosdata/TDengine/blob/main/docs/examples/java/src/main/java/com/taos/example/ParameterBindingFullDemo.java)
|
||||
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ws" label="WebSocket connection">
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/WSParameterBindingBasicDemo.java:para_bind}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/WSParameterBindingBasicDemo.java:para_bind}}
|
||||
```
|
||||
|
||||
This is the [Detailed Example](https://github.com/taosdata/TDengine/blob/main/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/WSParameterBindingFullDemo.java)
|
||||
This is the [Detailed Example](https://github.com/taosdata/TDengine/blob/main/docs/examples/java/src/main/java/com/taos/example/WSParameterBindingFullDemo.java)
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
@ -503,14 +503,14 @@ TDengine supports schemaless writing. It is compatible with InfluxDB's Line Prot
|
|||
<TabItem value="native" label="native connection">
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SchemalessJniTest.java:schemaless}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/SchemalessJniTest.java:schemaless}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ws" label="WebSocket connection">
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/SchemalessWsTest.java:schemaless}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/SchemalessWsTest.java:schemaless}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
@ -531,7 +531,7 @@ The TDengine Java client library supports subscription functionality with the fo
|
|||
#### Create a Topic
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ConsumerLoopImp.java:create_topic}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/ConsumerLoopImp.java:create_topic}}
|
||||
```
|
||||
|
||||
The preceding example uses the SQL statement `SELECT ts, current, voltage, phase, groupid, location FROM meters` and creates a topic named `topic_meters`.
|
||||
|
@ -540,7 +540,7 @@ The preceding example uses the SQL statement `SELECT ts, current, voltage, phase
|
|||
#### Create a Consumer
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/AbsConsumerLoop.java:create_consumer}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/AbsConsumerLoop.java:create_consumer}}
|
||||
```
|
||||
|
||||
- bootstrap.servers: `ip:port` where the TDengine server is located, or `ip:port` where the taosAdapter is located if WebSocket connection is used.
|
||||
|
@ -561,7 +561,7 @@ For more information, see [Consumer Parameters](../../../develop/tmq/#create-a-c
|
|||
#### Subscribe to consume data
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/AbsConsumerLoop.java:poll_data}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/AbsConsumerLoop.java:poll_data}}
|
||||
```
|
||||
|
||||
The parameters of the subscribe method are defined as: a list of topics to subscribe, and it supports subscribing to multiple topics at the same time.
|
||||
|
@ -588,7 +588,7 @@ void seekToEnd(Collection<TopicPartition> partitions) throws SQLException;
|
|||
Example usage is as follows.
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ConsumerOffsetSeek.java:consumer_seek}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/ConsumerOffsetSeek.java:consumer_seek}}
|
||||
```
|
||||
|
||||
#### Commit offset
|
||||
|
@ -622,14 +622,14 @@ For more information, see [Data Subscription](../../../develop/tmq).
|
|||
In addition to the native connection, the Java client library also supports subscribing via websocket.
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/ConsumerLoopFull.java:consumer_demo}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/ConsumerLoopFull.java:consumer_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="ws" label="WebSocket connection">
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/WsConsumerLoopFull.java:consumer_demo}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/WsConsumerLoopFull.java:consumer_demo}}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
@ -644,7 +644,7 @@ In addition to the native connection, the Java client library also supports subs
|
|||
Example usage is as follows.
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/connectionPools/src/main/java/com/taosdata/example/HikariDemo.java:connection_pool}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/HikariDemo.java:connection_pool}}
|
||||
```
|
||||
|
||||
> getConnection(), you need to call the close() method after you finish using it. It doesn't close the connection. It just puts it back into the connection pool.
|
||||
|
@ -655,14 +655,14 @@ Example usage is as follows.
|
|||
Example usage is as follows.
|
||||
|
||||
```java
|
||||
{{#include examples/JDBC/connectionPools/src/main/java/com/taosdata/example/DruidDemo.java:connection_pool}}
|
||||
{{#include docs/examples/java/src/main/java/com/taos/example/DruidDemo.java:connection_pool}}
|
||||
```
|
||||
|
||||
> For more questions about using druid, please see [Official Instructions](https://github.com/alibaba/druid).
|
||||
|
||||
### More sample programs
|
||||
|
||||
The source code of the sample application is under `TDengine/examples/JDBC`:
|
||||
The source code of the sample application is under `TDengine/docs/examples/JDBC`:
|
||||
|
||||
- JDBCDemo: JDBC sample source code.
|
||||
- connectionPools: using taos-jdbcdriver in connection pools such as HikariCP, Druid, dbcp, c3p0, etc.
|
||||
|
@ -671,7 +671,7 @@ The source code of the sample application is under `TDengine/examples/JDBC`:
|
|||
- springbootdemo: using taos-jdbcdriver in Springboot.
|
||||
- consumer-demo: consumer TDengine data example, the consumption rate can be controlled by parameters.
|
||||
|
||||
[JDBC example](https://github.com/taosdata/TDengine/tree/3.0/examples/JDBC)
|
||||
[JDBC example](https://github.com/taosdata/TDengine/tree/main/docs/examples/JDBC)
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ The TDengine Go client library supports subscription functionality with the foll
|
|||
|
||||
### More sample programs
|
||||
|
||||
* [sample program](https://github.com/taosdata/driver-go/tree/3.0/examples)
|
||||
* [sample program](https://github.com/taosdata/driver-go/tree/main/examples)
|
||||
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
|
|
@ -403,7 +403,7 @@ The following parameters can be configured for the TMQ DSN. Only `group.id` is m
|
|||
|
||||
#### Full Sample Code
|
||||
|
||||
For more information, see [GitHub sample file](https://github.com/taosdata/TDengine/blob/3.0/docs/examples/rust/nativeexample/examples/subscribe_demo.rs).
|
||||
For more information, see [GitHub sample file](https://github.com/taosdata/TDengine/blob/main/docs/examples/rust/nativeexample/examples/subscribe_demo.rs).
|
||||
|
||||
### Use with connection pool
|
||||
|
||||
|
@ -437,9 +437,9 @@ let taos = pool.get()?;
|
|||
|
||||
### More sample programs
|
||||
|
||||
The source code of the sample application is under `TDengine/examples/rust` :
|
||||
The source code of the sample application is under `TDengine/docs/examples/rust` :
|
||||
|
||||
[rust example](https://github.com/taosdata/TDengine/tree/3.0/examples/rust)
|
||||
[rust example](https://github.com/taosdata/TDengine/tree/main/docs/examples/rust)
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
|
|
|
@ -448,6 +448,7 @@ Response body:
|
|||
|
||||
```bash
|
||||
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
||||
curl -L -H "Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql
|
||||
```
|
||||
|
||||
Response body:
|
||||
|
@ -499,6 +500,7 @@ Response body:
|
|||
|
||||
```bash
|
||||
curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "create database demo" 192.168.0.1:6041/rest/sql
|
||||
curl -L -H "Authorization: Taosd /KfeAzX/f9na8qdtNZmtONryp201ma04bEl8LcvLUd7a8qdtNZmtONryp201ma04" -d "create database demo" 192.168.0.1:6041/rest/sql
|
||||
```
|
||||
|
||||
Response body:
|
||||
|
|
|
@ -69,7 +69,7 @@ This error indicates that the client could not connect to the server. Perform th
|
|||
|
||||
11. You can also use the TDengine CLI to diagnose network issues. For more information, see [Problem Diagnostics](https://docs.tdengine.com/operation/diagnose/).
|
||||
|
||||
### 3. How can I resolve the "Unable to resolve FQDN" error?
|
||||
### <a id='FQDN'>3. How can I resolve the "Unable to resolve FQDN" error? </a>
|
||||
|
||||
Clients and dnodes must be able to resolve the FQDN of each required node. You can confirm your configuration as follows:
|
||||
|
||||
|
@ -164,3 +164,7 @@ For more information, see [taosAdapter](https://docs.tdengine.com/reference/taos
|
|||
OOM errors are thrown by the operating system when its memory, including swap, becomes insufficient and it needs to terminate processes to remain operational. Most OOM errors in TDengine occur for one of the following reasons: free memory is less than the value of `vm.min_free_kbytes` or free memory is less than the size of the request. If TDengine occupies reserved memory, an OOM error can occur even when free memory is sufficient.
|
||||
|
||||
TDengine preallocates memory to each vnode. The number of vnodes per database is determined by the `vgroups` parameter, and the amount of memory per vnode is determined by the `buffer` parameter. To prevent OOM errors from occurring, ensure that you prepare sufficient memory on your hosts to support the number of vnodes that your deployment requires. Configure an appropriately sized swap space. If you continue to receive OOM errors, your SQL statements may be querying too much data for your system. TDengine Enterprise Edition includes optimized memory management that increases stability for enterprise customers.
|
||||
|
||||
### 14. How can I resolve the "some vnode/qnode/mnode(s) out of service" error?
|
||||
|
||||
The client has not configured FQDN for all servers. For example, the server has 3 nodes, while the client has only configured FQDN for 1 node. FQDN configuration refer to [How can I resolve the "Unable to resolve FQDN" error?](#FQDN)
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package com.taosdata.example;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class DruidDemo {
|
||||
// ANCHOR: connection_pool
|
||||
public static void main(String[] args) throws Exception {
|
||||
String url = "jdbc:TAOS://127.0.0.1:6030/log";
|
||||
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
// jdbc properties
|
||||
dataSource.setDriverClassName("com.taosdata.jdbc.TSDBDriver");
|
||||
dataSource.setUrl(url);
|
||||
dataSource.setUsername("root");
|
||||
dataSource.setPassword("taosdata");
|
||||
// pool configurations
|
||||
dataSource.setInitialSize(10);
|
||||
dataSource.setMinIdle(10);
|
||||
dataSource.setMaxActive(10);
|
||||
dataSource.setMaxWait(30000);
|
||||
dataSource.setValidationQuery("SELECT SERVER_VERSION()");
|
||||
|
||||
Connection connection = dataSource.getConnection(); // get connection
|
||||
Statement statement = connection.createStatement(); // get statement
|
||||
// query or insert
|
||||
// ...
|
||||
|
||||
statement.close();
|
||||
connection.close(); // put back to connection pool
|
||||
dataSource.close();
|
||||
}
|
||||
// ANCHOR_END: connection_pool
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.taosdata.example;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class HikariDemo {
|
||||
// ANCHOR: connection_pool
|
||||
public static void main(String[] args) throws Exception {
|
||||
HikariConfig config = new HikariConfig();
|
||||
// jdbc properties
|
||||
config.setJdbcUrl("jdbc:TAOS://127.0.0.1:6030/log");
|
||||
config.setUsername("root");
|
||||
config.setPassword("taosdata");
|
||||
// connection pool configurations
|
||||
config.setMinimumIdle(10); // minimum number of idle connection
|
||||
config.setMaximumPoolSize(10); // maximum number of connection in the pool
|
||||
config.setConnectionTimeout(30000); // maximum wait milliseconds for get connection from pool
|
||||
config.setMaxLifetime(0); // maximum life time for each connection
|
||||
config.setIdleTimeout(0); // max idle time for recycle idle connection
|
||||
config.setConnectionTestQuery("SELECT SERVER_VERSION()"); // validation query
|
||||
|
||||
HikariDataSource dataSource = new HikariDataSource(config); // create datasource
|
||||
|
||||
Connection connection = dataSource.getConnection(); // get connection
|
||||
Statement statement = connection.createStatement(); // get statement
|
||||
|
||||
// query or insert
|
||||
// ...
|
||||
statement.close();
|
||||
connection.close(); // put back to connection pool
|
||||
dataSource.close();
|
||||
}
|
||||
// ANCHOR_END: connection_pool
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue