Hello, Some comments inline,
2013/12/16 Stargate <[email protected]> > Hi, > > i have a problem with the setAutoCommit Option, this is not working in > JOOQ 2.6.1 and now i want migrate to JOOQ 3.2 i hope this will resolve my > AutoCommit Problem.. i use the Tomcat Pooling and a Postgres Database. Here > are some Infos how i have configured my pooling > http://stackoverflow.com/questions/20589693/autocommit-did-not-work-with-jooq-2-6-1-and-tomcat-pooling > > At the Moment i use JOOQ 2.6.1 with Spring. In the old Version with 2.6.1 > i have used a Factory and now i have migrate it from > > public Factoryt createFactory() { > Settings settings = new Settings(); > > settings.getExecuteListeners().add( > > "de.si.srv.data.SpringExceptionTranslationExecuteListener"); > return new Factory(dataSource, SQLDialect.POSTGRES, settings); > } > > > TO > > public DSLContext createFactory() { > //Settings settings = new Settings(); > > /*settings.getExecuteListeners().add( > > "de.si.srv.data.SpringExceptionTranslationExecuteListener");*/ > DSLContext create = DSL.using(dataSource, SQLDialect.POSTGRES); > > return create; > } > > > is this correct and what is with the Settings and the > SpringExceptionTranslationExecuteListener? The getExecuteListeners() is not > supported in JOOQ 3.2 > Yes, ExecuteListeners are a central part of jOOQ 3.x: http://www.jooq.org/doc/3.2/manual/sql-execution/execute-listeners But a couple of things have changed between major releases. I suggest you read the following section, documenting all the incompatible changes between jOOQ 2.x and 3.x: http://www.jooq.org/doc/3.2/manual/reference/migrating-to-3.0/ > > My SpringExceptionTranslationExecuteListener looks like this: > > public class SpringExceptionTranslationExecuteListener extends > DefaultExecuteListener { > > @Override > public void start(ExecuteContext ctx) { > DataSource dataSource = ctx.getDataSource(); > Connection c = DataSourceUtils.getConnection(dataSource); > ctx.setConnection(c); > } > > @Override > public void exception(ExecuteContext ctx) { > SQLException ex = ctx.sqlException(); > Statement stmt = ctx.statement(); > Connection con = ctx.getConnection(); > DataSource dataSource = ctx.getDataSource(); > JdbcUtils.closeStatement(stmt); > ctx.exception(getExceptionTranslator(dataSource).translate("jOOQ", > ctx.sql(), ex)); > } > > /** > * Return the exception translator for this instance. > * <p> > * Creates a default {@link SQLErrorCodeSQLExceptionTranslator} for the > * specified DataSource if none set, or a > * {@link SQLStateSQLExceptionTranslator} in case of no DataSource. > */ > public synchronized SQLExceptionTranslator getExceptionTranslator( > DataSource dataSource) { > final SQLExceptionTranslator exceptionTranslator; > if (dataSource != null) { > exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator( > dataSource); > } else { > exceptionTranslator = new SQLStateSQLExceptionTranslator(); > } > return exceptionTranslator; > } > } > > But ctx.getConnection(); and ctx.getDataSource(); are not supported in > JOOQ 3.2 do i still need the SpringExceptionTranslationExecuteListener in > Jooq 3.2 ? > Yes, some methods may have been renamed or removed. In particular, there is no way to directly access a DataSource via the ExecuteContext anymore. You might need to store a reference to it yourself. The connection can be obtained via ctx.connection(); > What is the easiest way to implement Transaction Handling with Jooq 3.2 !? > A good way of doing so is documented here: http://www.jooq.org/doc/3.2/manual/getting-started/tutorials/jooq-with-spring/ I suggest upgrading to the latest jOOQ 3.2.2 version, which fixes a concurrency issue in that area. Hope this helps, Lukas -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
