JDBC and NIO
843859Nov 16 2007 — edited Nov 20 2014Hi all,
I'm not sure whether this is the right place to post this, but I'll try.
I'm working on a multiplexed server application (using the java.nio.* classes). One issue is this--any successful client session is going to involve some DB access. What I don't want to do is, when one client's request is complete, hang up the Selector while waiting for the DB; I'd like the Selector to keep on processing other incoming client requests until the DB returns.
I can see how I'd do this by making a separate thread for the DB call...but that's not really the point of using NIO--if I'm making a separate thread for each client session anyway, I lose any advantage from multiplexing.
What I really need is something like the ability to throw JDBC Statements at the database (asynchronously) and have the results arrive in something like a Channel that I can poll periodically to see if there's anything there.
Is there an established technique for doing this sort of thing? If not, can anyone recommend a strategy?
Thanks much,
Avrom