javajdbccnosdb

I write data to cnosdb through jdbc, and the data writing is successful, but the returned interface is not the number of rows but -1. What's going on?


I write data to cnosdb through jdbc, and the data writing is successful, but the returned interface is not the number of rows but -1. What's going on?My code as follow:

step:

  1. creat a database;

    boolean rs002 = stmt.execute("CREATE DATABASE tc_between WITH TTL '100000d';");
            assertFalse(rs002);
    
  2. create table;

    boolean rs004 = stmt001.execute("CREATE TABLE IF NOT EXISTS m2(f0 BIGINT UNSIGNED, f1 BIGINT, TAGS(t0, t1));");
            assertFalse(rs004);
    
  3. insert data in tables;

    
    
            int rs005 = stmt001.executeUpdate("INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (1672301798050000000 AS TIMESTAMP), 'Ig.UZ', 531136669299148225, 'nA4C3DH~B ', 9223372036854775807),(CAST (1672301798060000000 AS TIMESTAMP), '263356943', 1040920791041719924, '', -9223372036854775807),(CAST (1672301798070000000 AS TIMESTAMP), '1040920791041719924', 442061994865016078, 'gE1B7c.', 0);");
            System.out.println(rs005);
            int rs006 = stmt001.executeUpdate("INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (3031647407609562138 AS TIMESTAMP), '1D75h', 4166390262642105876, '7ua', 0.0),(CAST (1079616064603730664 AS TIMESTAMP), '}', 7806435932478031652, 'EA26qy', 23.456), (CAST (263356943 AS TIMESTAMP), '0.6287658423307444', 5466573340614276155, ',JC51Fh', -23.456), (CAST (1742494251700243812 AS TIMESTAMP), '#f^uE1B7KruC7BFz', 196790207, 'aF', 0.123);");
            assertEquals(4, rs006);
            int rs007 = stmt001.executeUpdate("INSERT m2(TIME, t0, f0, t1, f1) VALUES(CAST (3584132160280509277 AS TIMESTAMP), '', 4132058214182166915, 'V*1lE/', -0.123);");
            assertEquals(1, rs007);
            ResultSet rs008 = stmt001.executeQuery("SELECT m2.f0 FROM m2 WHERE CAST(0 AS STRING) BETWEEN (CAST( starts_with(m2.t0, m2.t1) AS STRING)) AND (m2.t1);");
            rs008.next();
            System.out.println(rs008.getString(1));
            stmt001.close();
            conn001.close();
    

the logs as follow:

[ERROR]   AppTest.test_Jdbc_betweensql:66 expected:<4> but was:<-1>

and then check the cnosdb info, as follow:

log 2
tc_between ❯ select * from m2;
+-------------------------------+---------------------+------------+---------------------+----------------------+

| time                          | t0                  | t1         | f0                  | f1                   |
+-------------------------------+---------------------+------------+---------------------+----------------------+
| 2025-03-20T18:10:51.700243812 | #f^uE1B7KruC7BFz    | aF         | 196790207           | 0                    |
| 2004-03-18T13:21:04.603730664 | }                   | EA26qy     | 7806435932478031652 | 23                   |
| 2066-01-25T12:16:47.609562138 | 1D75h               | 7ua        | 4166390262642105876 | 0                    |
| 2022-12-29T08:16:38.070       | 1040920791041719924 | gE1B7c.    | 442061994865016078  | 0                    |
| 1970-01-01T00:00:00.263356943 | 0.6287658423307444  | ,JC51Fh    | 5466573340614276155 | -23                  |
| 2022-12-29T08:16:38.050       | Ig.UZ               | nA4C3DH~B  | 531136669299148225  | 9223372036854775807  |
| 2022-12-29T08:16:38.060       | 263356943           |            | 1040920791041719924 | -9223372036854775807 |
+-------------------------------+---------------------+------------+---------------------+----------------------+
Query took 0.100 seconds.

Solution

  • Currently cnosdb-flight-sql is not fully implemented.