Skip to main content

Connect with Java

Add Dependency


view source code


Run this command in your terminal to save the JDBC URL as variable, or if it is a Spring application, you can use the Spring configuration:

export TDENGINE_JDBC_URL="<jdbcURL>"

Replace <jdbcURL> with real JDBC URL, it will seems like: jdbc:TAOS-RS://

To obtain the value of JDBC URL, please log in TDengine Cloud and click "Programming" on the left menu, then select "Java".


Code bellow get JDBC URL from environment variables first and then create a Connection object, which is a standard JDBC Connection object.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class ConnectCloudExample {
public static void main(String[] args) throws SQLException {
String jdbcUrl = System.getenv("TDENGINE_JDBC_URL");
try(Connection conn = DriverManager.getConnection(jdbcUrl)) {
try(Statement stmt = conn.createStatement()) {
stmt.executeQuery("select server_version()");

view source code

The client connection is then established. For how to write data and query data, please refer to Insert and Query.

For more details about how to write or query data via REST API, please check REST API.