推特 阿里云技术文档正文

创建时空表_开发指南_时序时空数据库TSDB2.0_时序时空数据库TSDB

admin 阿里云技术文档 2020-02-11 180 0
阿里云服务器优惠

创建时空表

 创建时空表,数据库账号使用普通账号即可。

注意: getConnection中host地址,用户名/密码,根据自己实例情况填写。

  1. public class CreateJDBC {
  2. public static void main(String args[]) {
  3. Connection conn = null;
  4. Statement stmt = null;
  5. try{
  6. Class.forName("org.postgresql.Driver");
  7. //用户请使用自己的账号和密码
  8. conn = DriverManager.getConnection("jdbc:postgresql://139.224.168.86:5432/doc","citybrain", "Tsdb2gaia");
  9. stmt = conn.createStatement();
  10. String sql = "CREATE TABLE tsdb_test( uid bigint, time timestamp, speed float, position GEO_SHAPE) CLUSTERED INTO 20 SHARDS ;" ;
  11. stmt.executeUpdate(sql);
  12. stmt.close();
  13. conn.close();
  14. } catch (Exception e) {
  15. System.err.println(e.getClass().getName() + " : " + e.getMessage());
  16. System.exit(0);
  17. }
  18. System.out.println("Create table successfully");
  19. }
  20. }
版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

评论

-----