diff --git a/tests/examples/JDBC/JDBCDemo/pom.xml b/tests/examples/JDBC/JDBCDemo/pom.xml
index b2fdc1ab299e57ea5de141d44f6ec747084d5483..80bc22b7c7d712dfae0cb951a7ee4f76f874e8c4 100644
--- a/tests/examples/JDBC/JDBCDemo/pom.xml
+++ b/tests/examples/JDBC/JDBCDemo/pom.xml
@@ -10,12 +10,6 @@
sudo apt-get install maven+``` +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: -
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo"+``` +mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" +``` + and run with your customed args -
mvn clean compile exec:java -Dexec.mainClass="com.taosdata.example.JdbcDemo" -Dexec.args="-host [HOSTNAME]"+``` +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 -
mvn clean package assembly:single -+``` -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 -
java -jar JDBCDemo-SNAPSHOT-jar-with-dependencies.jar -host localhostdiff --git a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java index 821248d16bdca0883b4e73706244c552f2562a22..93f59a89825f1d0bc76827114eb6cd247ee5c1eb 100644 --- a/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java +++ b/tests/examples/JDBC/JDBCDemo/src/main/java/com/taosdata/example/JDBCDemo.java @@ -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(); } }