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
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>
<pre>sudo apt-get install maven</pre>
## Compile and Install JDBC Driver
## Install TDengine Client
TDengine's JDBC driver jar is not yet published to maven center repo, so we need to manually compile it and install it to the local Maven repository. This can be easily done with Maven. Go to source directory of the JDBC driver ``TDengine/src/connector/jdbc`` and execute
Make sure you have already installed a tdengine client on your current develop environment.
<pre>mvn clean package install</pre>
Download the tdengine package on our website: ``https://www.taosdata.com/cn/all-downloads/`` and install the client.
## Compile the Demo Code and Run It
## Compile the Demo Code and Run It
To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
To compile the demo project, go to the source directory ``TDengine/tests/examples/JDBC/JDBCDemo`` and execute
<pre>mvn clean assembly:single package</pre>
<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 ``examples/JDBC/JDBCDemo/target`` and execute
The ``pom.xml`` is configured to package all the dependencies into one executable jar file.
System.out.printf("Column%d: name = %s, type = %d, type name = %s, display size = %d\n",column,metaData.getColumnName(column),metaData.getColumnType(column),
return"select avg("+field+"),min("+field+"),max("+field+") from "+dbName+"."+stbName+" where location = '"+locations[random.nextInt(locations.length)]+"'";