Hello, Thank you Gary for you reply, but it doesn’t work with configuring BasicDataSource with : dataSource.setDefaultAutoCommit(false); dataSource.setAutoCommitOnReturn(false); dataSource.setRollbackOnReturn(false);
There are changes, but always transactional with "SET autocommit" : SELECT @@session.transaction_isolation SELECT 1 -- ValidationQuery dans ConnectionFactory SET autocommit=0 SET SQL_SELECT_LIMIT=1 select date,logger,level,message,exception,pid,idUtilisateur,version,ip,markerSimpleName,sqlLastInsertId,sqlTimeMillis from log4j2 where 1=0 SET SQL_SELECT_LIMIT=DEFAULT insert into log4j2 (date,logger,level,message,exception,pid,idUtilisateur,version,ip,markerSimpleName,sqlLastInsertId,sqlTimeMillis) values (... the values ...) commit Also before returning the connection to my log4j2 Async Appenders whith ConnectionFactory, I force : connection.setAutoCommit(false); But result is same with transactional statements : SET autocommit=0 -- [ OR "SET autocommit=0" WITH connection.setAutoCommit(true); ] SET autocommit=0 SET SQL_SELECT_LIMIT=1 select date,logger,level,message,exception,pid,idUtilisateur,version,ip,markerSimpleName,sqlLastInsertId,sqlTimeMillis from log4j2 where 1=0 SET SQL_SELECT_LIMIT=DEFAULT insert into log4j2 (date,logger,level,message,exception,pid,idUtilisateur,version,ip,markerSimpleName,sqlLastInsertId,sqlTimeMillis) values ... commit Cheers. -----Message d'origine----- De : Gary Gregory <[email protected]> Envoyé : mercredi 1 juin 2022 14:57 À : Commons Users List <[email protected]> Objet : Re: DBCP Database Connection Pools without transactionnal NO autocommit Hello, Try calling Connection#setAutoCommit(false) once you get a Connection. You'll likely want to configure your data source with org.apache.commons.dbcp2.BasicDataSource.setAutoCommitOnReturn(false) to avoid resetting the auto-commit flag. Gary On Tue, May 31, 2022 at 7:46 PM Sébastien Jachym <[email protected]> wrote: > > Hy, is a way to fully disabled transactional (autocommit) statement in > DBCP ? > > > > Using Database Connection Pools with > org.apache.commons.dbcp2.BasicDataSource give me statements : > > > > SET autocommit=1 > > SET autocommit=0 > > SET SQL_SELECT_LIMIT=1 > > select > date,logger,level,message,exception,pid,idUtilisateur,version,ip,marke > rSimpleName,sqlLastInsertId,sqlTimeMillis > from log4j2 where 1=0 > > SET SQL_SELECT_LIMIT=DEFAULT > > insert into log4j2 > (date,logger,level,message,exception,pid,idUtilisateur,version,ip,mark > erSimpleName,sqlLastInsertId,sqlTimeMillis) > values > ('2022-06-01','timertask','TRACE','WaitInitService','','45964','123',' > null','','','','0') > > commit > > rollback > > SET autocommit=1 > > > > But it's for MySQL MyISAM table, and I didn't need transactions, I > whish only : > > > > select > date,logger,level,message,exception,pid,idUtilisateur,version,ip,marke > rSimpleName,sqlLastInsertId,sqlTimeMillis > from log4j2 where 1=0 > > SET SQL_SELECT_LIMIT=DEFAULT > > insert into log4j2 > (date,logger,level,message,exception,pid,idUtilisateur,version,ip,mark > erSimpleName,sqlLastInsertId,sqlTimeMillis) > values > ('2022-06-01','timertask','TRACE','WaitInitService','','45964','123',' > null','','','','0') > > > > Thanks for you replys. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
