Hi Radoslaw

We've been giving this topic some initial thought but as you've discovered
yourself, it is very hard (if even possible) to implement asynchronous
querying through the JDBC API.

I'm aware of these asynchronous PostgreSQL libraries that are truly
asynchronous down to the wire. Getting these things right is very hard,
when you need to reimplement the data transfer protocol of any given
database, though, so I trust that these libraries are still at a very early
stage. Consider how it took more than a decade for JDBC implementations to
become (almost) bug-free.

I suspect that right now, your solution of using jOOQ to generate SQL
strings might be as good as it gets.

2014-05-29 10:28 GMT+02:00 <[email protected]>:

> Hi,
> I've got a vert.x project where I don't want to use blocking query
> execution with a standard sql driver but I want still to use Jooq.
> I'm lookoing for a way to use Jooq in an event-driven manner, so that not
> only when I fetch a query I pass a callback, but also Jooq does not block
> when it directly executes a query.
> There's even an asynchronous database driver project which could be used:
> https://github.com/mauricio/postgresql-async. Unfortunetaly its
> interfaces are not compatible with java.sql (ex. Connection, ResultSet
> etc.).
>
> So far I've managed to create a very simple solution which uses Jooq to
> build and return SQL query in a string, which I pass to the asynchronous
> driver to get a result. But there are multiple drawbacks: I can't use jooq
> fetch methods (ex. fetchInto, fetchMap etc.), I don't see a way to create a
> Jooq-like result (Result<Record>) so I loose the type safety Jooq provides.
>
> Has anyone had a similiar issue and managed to come up with smth?
>

I'll leave that question to the group


> I tried to observe how Jooq executes queries and frankly I don't see a way
> to make it work without waiting.
>

That's probably true. However, you might be able to wrap that library
behind the JDBC API, specifically wrapping the Future types that model
result sets behind a JDBC ResultSet. If you're using jOOQ's
ResultQuery.fetchLazy(), you might then be able to postpone ResultSet
consumption. However, you'll probably make quite some compromise with
respect to true asynchronous programming...


> Is there a simple way to build a jooq-like result with Record, knowing the
> column names?
>

Yes, there are DSLContext.newResult() and DSLContext.newRecord();
-
http://www.jooq.org/javadoc/latest/org/jooq/DSLContext.html#newRecord(org.jooq.Table)
-
http://www.jooq.org/javadoc/latest/org/jooq/DSLContext.html#newResult(org.jooq.Table)

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

Reply via email to