use of org.jooq.impl.DefaultExecuteListenerProvider in project jOOQ by jOOQ.
the class Example_4_4_ExecuteListener method run.
@Test
public void run() {
Tools.title("Displaying execution time using a custom ExecuteListener");
ExecuteListener listener = new CallbackExecuteListener().onStart(ctx -> {
// Register the start time to the current context
ctx.data("time", System.nanoTime());
}).onEnd(ctx -> {
// Extract the start time from the current context
Long time = (Long) ctx.data("time");
System.out.println("Execution time : " + ((System.nanoTime() - time) / 1000 / 1000.0) + "ms. Query : " + ctx.sql());
});
DSL.using(new DefaultConfiguration().set(SQLDialect.H2).set(new DefaultConnectionProvider(connection())).set(new DefaultExecuteListenerProvider(listener))).select(AUTHOR.ID).from(AUTHOR).fetch();
}
use of org.jooq.impl.DefaultExecuteListenerProvider in project tutorials by eugenp.
the class PersistenceContextIntegrationTest method configuration.
@Bean
public DefaultConfiguration configuration() {
DefaultConfiguration jooqConfiguration = new DefaultConfiguration();
jooqConfiguration.set(connectionProvider());
jooqConfiguration.set(new DefaultExecuteListenerProvider(exceptionTransformer()));
String sqlDialectName = environment.getRequiredProperty("jooq.sql.dialect");
SQLDialect dialect = SQLDialect.valueOf(sqlDialectName);
jooqConfiguration.set(dialect);
return jooqConfiguration;
}
Aggregations