全部产品

插入数据

更新时间:2019-12-30 10:22:55

写入point点数据。支持标准的点线面,多点、多线等OGC标准。

  1. public class InsertJDBC {
  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. conn.setAutoCommit(false);
  10. stmt = conn.createStatement();
  11. String sql = "INSERT INTO tsdb_test VALUES (1001, '2019-03-11 16:34:15', 1002.2, ST_MakePoint(10.3,20.1) )" ;
  12. stmt.executeUpdate(sql);
  13. sql = "INSERT INTO tsdb_test VALUES (1002, '2019-03-12 16:34:15', 2002.2, ST_MakePoint(1.3,2.1) )";
  14. stmt.executeUpdate(sql);
  15. sql = "INSERT INTO tsdb_test VALUES (1003, '2019-03-13 16:34:15', 3002.2, ST_MakePoint(30.3,40.1) )";
  16. stmt.executeUpdate(sql);
  17. stmt.close();
  18. conn.commit();
  19. conn.close();
  20. } catch (Exception e) {
  21. System.err.println(e.getClass().getName() + " : " + e.getMessage());
  22. System.exit(0);
  23. }
  24. System.out.println("select successfully");
  25. }
  26. }