After seeing a talk on the library, I'm attempting to integrate Jooq as 
it's the best thing since sliced bread.  However, I'm having some 
difficulty attempting to integrate it fully with try with resources.  You 
see, I hate squigglies with finally blocks full of close().

The best I've come up with so far is to generate a prepared statement using 
a jooq in a second method, then execute that with jdbc and 
try-with-resources.  I'm only using JOOQ's string builder capabilities.


        try (Connection localConnection = Persist.connectionPool.
getConnection();
             PreparedStatement statement = buildPreloadQuery(localConnection
);
             ResultSet rs = statement.executeQuery()) {


private static PreparedStatement buildPreloadQuery(Connection 
localConnection) throws SQLException {
        PreparedStatement outStatement;
        DSLContext create;


        create = DSL.using(localConnection, SQLDialect.MYSQL);
        SelectQuery query = create.selectQuery();


        query.addSelect(OBJECT_TABLE.PARENT);
        query.addFrom(OBJECT_TABLE);
        query.addLimit(10000);


        outStatement = localConnection.prepareStatement(create.renderInlined
(query););
        query.close();


        return outStatement;
    }


I have the following questions.

1) Is there an example of best practices I can follow, of clean Jooq 
integration with try with resources?  I'd really like to use all of Jooq's 
CRUD capabilites but don't want to go back to java 6 conventions.
2) Is there a way to access a query object's internal prepared statement 
directly so I don't have to regenerate it?  It doesn't appear to be exposed.

-- 
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/d/optout.

Reply via email to