change
This commit is contained in:
parent
b1862fef52
commit
bcc8dabd03
|
@ -10,12 +10,6 @@
|
|||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
|
@ -49,14 +43,8 @@
|
|||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.taosdata.jdbc</groupId>
|
||||
<artifactId>taos-jdbcdriver</artifactId>
|
||||
<version>2.0.15</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# How to Run the JDBC Demo Code On Linux OS
|
||||
TDengine's JDBC demo project is organized in a Maven way so that users can easily compile, package and run the project. If you don't have Maven on your server, you may install it using
|
||||
<pre>sudo apt-get install maven</pre>
|
||||
```
|
||||
sudo apt-get install maven
|
||||
```
|
||||
|
||||
|
||||
## Install TDengine Client
|
||||
Make sure you have already installed a tdengine client on your current develop environment.
|
||||
|
@ -8,19 +11,31 @@ Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-
|
|||
|
||||
## Run jdbcDemo using mvn plugin
|
||||
run command:
|
||||
<pre> mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo"</pre>
|
||||
```
|
||||
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo"
|
||||
```
|
||||
|
||||
and run with your customed args
|
||||
<pre>mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -Dexec.args="-host [HOSTNAME]"</pre>
|
||||
```
|
||||
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -Dexec.args="-host [HOSTNAME]"
|
||||
```
|
||||
|
||||
## Compile the Demo Code and Run It
|
||||
|
||||
To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
|
||||
```
|
||||
cd TDengine/src/connector/jdbc
|
||||
|
||||
mvn clean package -Dmaven.test.skip=true
|
||||
|
||||
cp target/taos-jdbcdriver-2.0.x-dist.jar ../../../tests/examples/JDBC/JDBCDemo/target/
|
||||
|
||||
cd ../../../tests/examples/JDBC/JDBCDemo
|
||||
|
||||
<pre>
|
||||
mvn clean package assembly:single
|
||||
</pre>
|
||||
```
|
||||
|
||||
The ``pom.xml`` is configured to package all the dependencies into one executable jar file.
|
||||
To run it, go to ``TDengine/tests/examples/JDBC/JDBCDemo/target`` and execute
|
||||
```
|
||||
java -Djava.ext.dirs=.:$JAVA_HOME/jre/lib/ext -jar JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host localhost
|
||||
```
|
||||
|
||||
To run it, go to ``examples/JDBC/JDBCDemo/target`` and execute
|
||||
<pre>java -jar JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host localhost</pre>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.taosdata.example;
|
||||
|
||||
import com.taosdata.jdbc.TSDBDriver;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -39,16 +37,16 @@ public class JDBCDemo {
|
|||
try {
|
||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_HOST, host);
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8");
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8");
|
||||
properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
||||
properties.setProperty("host", host);
|
||||
properties.setProperty("charset", "UTF-8");
|
||||
properties.setProperty("locale", "en_US.UTF-8");
|
||||
properties.setProperty("timezone", "UTC-8");
|
||||
System.out.println("get connection starting...");
|
||||
connection = DriverManager.getConnection("jdbc:TAOS://" + host + ":0/", properties);
|
||||
if (connection != null)
|
||||
System.out.println("[ OK ] Connection established.");
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
throw new RuntimeException("connection failed: " + host);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue