@Grab('com.h2database:h2:1.4.190') @GrabConfig(systemClassLoader = true) import groovy.sql.Sql class Query { private final String query Query(String query) { this.query = query } QueryExecutor with(Object... params) { new QueryExecutor(query, params) } } class QueryExecutor { private final String cs = 'jdbc:h2:mem:' private final String driver = 'org.h2.Driver' private final String query private final Object[] params QueryExecutor(String query, Object[] params) { this.query = query this.params = params } void execute() { Sql.newInstance(cs, driver).execute(query, params) } } new Query('SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = ?') .with('HELP') .execute()