bw-chuxin commented on issue #45940:
URL: https://github.com/apache/doris/issues/45940#issuecomment-2562128247

   doris建表语句
   ``` sql
   CREATE TABLE `test1` (
     `id` VARCHAR(32) NOT NULL,
     `dept_id` VARCHAR(32) NOT NULL,
     `name` VARCHAR(100) NULL,
     `create_time` DATETIME NULL
   ) ENGINE=OLAP
   UNIQUE KEY(`id`, `dept_id`)
   COMMENT 'OLAP'
   DISTRIBUTED BY HASH(`id`) BUCKETS 1
   PROPERTIES (
   "replication_allocation" = "tag.location.default: 1"
   ); 
   ```
   mysql 驱动
   ``` xml
   <dependency>
         <groupId>com.mysql</groupId>
         <artifactId>mysql-connector-j</artifactId>
         <version>8.0.31</version>
       </dependency>
   ````
   
   测试java代码
   jdbcurl
   ```
   
jdbc:mysql://ip:端口/数据库?useServerPrepStmts=true&useLocalSessionState=true&rewriteBatchedStatements=true&cachePrepStmts=true&prepStmtCacheSqlLimit=9999&prepStmtCacheSize=9999999
   ```
   ``` java
   public static void main( String[] args ) throws SQLException, IOException {
           String jdbcUrl = args[0];
           String username = args[1];
           String password = args[2];
   
           Properties props = new Properties();
           props.put("user", username);
           props.put("password", password);
   
   
           try (Connection conn = DriverManager.getConnection(jdbcUrl, props)) {
               conn.createStatement().execute("set group_commit = async_mode;");
   
               String query = "insert into test1" + " values(?, ?, ?,?)";
               try (PreparedStatement stmt = conn.prepareStatement(query)) {
                   for (int j = 0; j < 10; j++) {
                       long start = System.currentTimeMillis();
                       // 10 rows per insert
                       for (int i = 0; i < 17000 + j; i++) {
                           stmt.setInt(1, i);
                           stmt.setString(2, i +"");
                           stmt.setString(3, "name" + i);
                           stmt.setTimestamp(4, 
Timestamp.valueOf(LocalDateTime.now()));
                           stmt.addBatch();
                       }
                       int[] result = stmt.executeBatch();
                       long end = System.currentTimeMillis();
                       System.out.println("insert " + result.length + " rows" + 
" cost time: " + (end - start) + "ms");
                   }
               }
           } catch (Exception e) {
               e.printStackTrace();
           }
       }
   ```
   
   报错信息
   ```
   java.lang.ArrayIndexOutOfBoundsException: 2464
        at 
com.mysql.cj.NativeQueryBindings.getBinding(NativeQueryBindings.java:191)
        at 
com.mysql.cj.NativeQueryBindings.setFromBindValue(NativeQueryBindings.java:198)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.setOneBatchedParameterSet(ClientPreparedStatement.java:591)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchWithMultiValuesClause(ClientPreparedStatement.java:675)
        at 
com.mysql.cj.jdbc.ClientPreparedStatement.executeBatchInternal(ClientPreparedStatement.java:409)
        at com.mysql.cj.jdbc.StatementImpl.executeBatch(StatementImpl.java:795)
        at com.dlink.App.main(App.java:44)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to