I’ve already written several times about Akka and async programming with it. For example doing access files and webservices with it. So async API stack is complete, right?
We’ve got async network and web access via NIO and frameworks like Play 2.0, Spray, HTTPClient etc. And with NIO 2 we easily can access the file system in asynchronous way.
But wait, what about your database? What if tons of yourdata sits in a good old relational database? Unfortunately the current JDBC model is blocking by definition. No asynchronous operation isallowed.
The standard way of doing things for async SQL operations is to use some background threads and do things there. And for many applications this is good enough.
But if you do more and more db operations you start to consume more and more threads, which will be waiting for blocking operations. Wouldn’t it be nicer if the database operations are truly asynchronous like other operations?
JDBC is nice, but let's you wait
So I’ve looked for an alternative to JDBC. I’ve found two approaches to provide a asynchronous JDBC alternative.
The async-mysql-connector and ADBCJ. Unfortunate both are not really actively maintained. Anyhow I decided to go ahead with ADBCJ. More about that later. Let’s first take a look at how we to use everything.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/301743/viewspace-731245/，如需转载，请注明出处，否则将追究法律责任。