提交 cce6dc73 编写于 作者: B BoDing

docs: java connect example free resource

上级 755af48f
...@@ -10,12 +10,12 @@ import java.sql.Statement; ...@@ -10,12 +10,12 @@ import java.sql.Statement;
public class ConnectCloudExample { public class ConnectCloudExample {
public static void main(String[] args) throws SQLException { public static void main(String[] args) throws SQLException {
String jdbcUrl = System.getenv("TDENGINE_JDBC_URL"); String jdbcUrl = System.getenv("TDENGINE_JDBC_URL");
Connection conn = DriverManager.getConnection(jdbcUrl); try(Connection conn = DriverManager.getConnection(jdbcUrl)) {
Statement stmt = conn.createStatement(); try(Statement stmt = conn.createStatement()) {
// test the connection by firing a query // test the connection by firing a query
stmt.executeQuery("select server_version()"); stmt.executeQuery("select server_version()");
stmt.close(); }
conn.close(); }
} }
} }
// ANCHOR_END: connect // ANCHOR_END: connect
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册