brettwooldridge / HikariCP

光 HikariCP・A solid, high-performance, JDBC connection pool at last.
Apache License 2.0
19.91k stars 2.92k forks source link

question: how does `prepStmtCacheSize` property work #2193

Open Divine1 opened 5 months ago

Divine1 commented 5 months ago

Assume that i have set below values

prepStmtCacheSize 40
prepStmtCacheSizeSqlLimit 2048

In below code, before con.commit() gets executed, will prepStmtCache hold 1 value (the insert statement) or 1000 values (the insert statement with values) ?

String sql="insert into mydept values ( ?,?,? )";
PreparedStatement preparedStatement =con.prepareStatement(sql);

for(int i=0;i<1000;i++) {
preparedStatement.setInt(1, deptno+i);
preparedStatement.setString(2, deptname);
preparedStatement.setString(3, location);
preparedStatement.addBatch();
}

int retval[] = preparedStatement.executeBatch();
//int retval = preparedStatement.executeUpdate();
//System.out.println("retval "+retval+" deptno "+deptno);
con.commit();
con.close();