提交 7529438c 编写于 作者: D dingbo

docs: update java demo code

上级 17e29394
...@@ -13,12 +13,12 @@ pip3 install taospy>=2.3.3 ...@@ -13,12 +13,12 @@ pip3 install taospy>=2.3.3
You'll need to have Python3 installed. You'll need to have Python3 installed.
## Config ## Config {#config}
Run this command in your terminal to save your url and token as variables: Run this command in your terminal to save your URL and token as variables:
```bash ```bash
export TDENGINE_CLOUD_URL=<url> export TDENGINE_CLOUD_URL=<URL>
export TDENGINE_CLOUD_TOKEN=<token> export TDENGINE_CLOUD_TOKEN=<token>
``` ```
...@@ -29,7 +29,7 @@ You should replace above placeholders as real values. To obtain these values, pl ...@@ -29,7 +29,7 @@ You should replace above placeholders as real values. To obtain these values, pl
::: :::
<!-- exclude-end --> <!-- exclude-end -->
## Connect ## Connect {#connect}
```python ```python
import taosrest import taosrest
......
...@@ -23,7 +23,7 @@ dependencies { ...@@ -23,7 +23,7 @@ dependencies {
} }
``` ```
## Config ## Config {#config}
Run this command in your terminal to save your url and token as variables: Run this command in your terminal to save your url and token as variables:
...@@ -40,22 +40,21 @@ You should replace above placeholders as real values. To obtain these values, pl ...@@ -40,22 +40,21 @@ You should replace above placeholders as real values. To obtain these values, pl
::: :::
<!-- exclude-end --> <!-- exclude-end -->
## Connect ## Connect {#connect}
```java ```java
import com.taosdata.jdbc.TSDBDriver; import com.taosdata.jdbc.rs.RestfulConnection;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException;
public class ConnectCloudExample { public class ConnectCloudExample {
public static void main(String[] args) throws SQLException { public static void main(String[] args) throws Exception {
String url = System.getenv("TDENGINE_CLOUD_URL"); String url = System.getenv("TDENGINE_CLOUD_URL");
String token = System.getenv("TDENGINE_CLOUD_TOKEN"); String token = System.getenv("TDENGINE_CLOUD_TOKEN");
Connection conn = TSDBDriver.connect(url, token); // demo code for discussion. // create a standard JDBC connection.
Connection conn = new RestfulConnection(url, token);
} }
} }
``` ```
The client connection is then established. The client connection is then established.
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册