private void setupDatabase() { System.setProperty("org.jooq.no-logo", "true"); dataSource = dataSourceFactory.createDataSource("cattle"); DataSourceConnectionProvider dscp = new DataSourceConnectionProvider(dataSource); ThreadLocalTransactionProvider tp = new ThreadLocalTransactionProvider(dscp, false); LoggerListener logger = new LoggerListener(); logger.setMaxLength(1000); ExecuteListener[] listeners = new ExecuteListener[] { logger, new StopWatchListener() }; Settings settings = dbSetting("cattle"); jooqConfig = new DefaultConfiguration() .set(getSQLDialect("cattle")) .set(settings) .set(dscp) .set(tp) .set(DefaultExecuteListenerProvider.providers(listeners)); }
@PostConstruct public void init() { String prop = "db." + name + ".database"; String database = ArchaiusUtil.getString(prop).get(); if ( database == null ) { throw new IllegalStateException("Failed to find config for [" + prop + "]"); } try { SQLDialect dialect = SQLDialect.valueOf(database.trim().toUpperCase()); set(dialect); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException("Invalid SQLDialect [" + database.toUpperCase() + "]", e); } if ( connectionProvider == null ) { set(new AutoCommitConnectionProvider(dataSource)); } else { set(connectionProvider); } settings.setRenderSchema(false); String renderNameStyle = ArchaiusUtil.getString("db." + name + "." + database + ".render.name.style").get(); if ( renderNameStyle != null ) { settings.setRenderNameStyle(RenderNameStyle.valueOf(renderNameStyle.trim().toUpperCase())); } set(settings); if ( listeners != null && listeners.size() > 0 ) { settings().setExecuteLogging(false); set(DefaultExecuteListenerProvider.providers(listeners.toArray(new ExecuteListener[listeners.size()]))); } }
@PostConstruct public void init() { String prop = "db." + name + ".database"; String database = ArchaiusUtil.getString(prop).get(); if ( database == null ) { throw new IllegalStateException("Failed to find config for [" + prop + "]"); } try { SQLDialect dialect = SQLDialect.valueOf(database.trim().toUpperCase()); set(dialect); } catch ( IllegalArgumentException e ) { throw new IllegalArgumentException("Invalid SQLDialect [" + database.toUpperCase() + "]", e); } if ( connectionProvider == null ) { set(new AutoCommitConnectionProvider(dataSource)); } else { set(connectionProvider); } Settings settings = new Settings(); settings.setRenderSchema(false); String renderNameStyle = ArchaiusUtil.getString("db." + name + "." + database + ".render.name.style").get(); if ( renderNameStyle != null ) { settings.setRenderNameStyle(RenderNameStyle.valueOf(renderNameStyle.trim().toUpperCase())); } set(settings); if ( listeners != null && listeners.size() > 0 ) { settings().setExecuteLogging(false); set(DefaultExecuteListenerProvider.providers(listeners.toArray(new ExecuteListener[listeners.size()]))); } }
@Override public ExecuteListener provide() { return null; }
public List<ExecuteListener> getListeners() { return listeners; }
public void setListeners(List<ExecuteListener> listeners) { this.listeners = listeners; }