If you do not want to do this through the URL, you can use the Properties object with the DriverManager :
Properties props = new Properties(); props.setProperty("user", ...); props.setProperty("password", ...); props.setProperty("rewriteBatchedStatements", "true"); Connection connection = DriverManager.getConnection(url, props);
If you are using MysqlDataSource or MysqlConnectionPoolDataSource , you need to set the rewriteBatchedStatements (or set setter setRewriteBatchedStatements(boolean) property
To change this at runtime after you receive the connection, you can use:
((com.mysql.jdbc.ConnectionProperties) connection).setRewriteBatchedStatements(true);
Note. I just looked at the sources of MySQL Connector / J for this last parameter, I have not tested it.
UPDATED
For c3p0 you can use the following:
ComboPooledDataSource cpds = ... Connection connection = cpds.getConnection(); connection.unwrap(com.mysql.jdbc.ConnectionProperties.class).setRewriteBatchedStatements(true);
c3p0 should be com.mchange:c3p0:0.9.5.2 , be careful with com.mchange - with another group. This code does not work.
source share