It has been a while since I wrote any serious technical stuff. Previously I’ve already written a bit about asynchronous database access.
I’ve been continuing work on this, mainly on the basics, the ADBCJ driver implementation . Here’s a overview of the updates:
- Simple connection pool: This helps to avoid the costs of creating connections. It also gives a nice control how many connections are used.
- H2-Support: Implemented a driver for the H2 database
- MySQL Driver Restructuring: The driver has been massively simplified, mainly in term of synchronization. This makes it easier to debug and reason about it.
- DBFuture implementation moved to CAS operations instead of locks: Less overhead, simplifies implementation and avoids potential dead locks
- Dropped PostgreSQL driver for now: I never maintained that driver, so I dropped it for now. If someone has interrest in a PostgreSQL driver, talk to me.
- Countless bugfixes
In the JDBC world connection pools are the standard. And this has it’s reasons. Connection to a database needs some initial work. With a connection pool this overhead is avoided. Plus it gives you control how many connections are used. ADBCJ has now a connection-pool too.
First you need to add the pool implementation to your project:
After that you add the prefix pooled to the connection string. This will load the ADBCJ connection pool. For examples:
The connection pool can be configured by providing properties for it. Here are the supported properties with the defaults:
I really like the H2 database. It’s simply to handle, embed, run and operate. I often use it for smaller projects, testing, default embedded database and so on. So no wonder, I’ve added support for it. You can add it via Maven/sbt.
First you need to add the driver to your project:
And then you can use the driver:
The synchronization of the requests and running operations in the MySQL driver was quite complex. This caused a lot of head aches fixing race conditions and finding errors. I’ve rewritten the internal synchronization of the MySQL driver to be simpler and more understandable.
Another side effect is, that the driver now pipelines request much more aggressively. This should improve performance in some scenario drastically. The cost of this is that most requests cannot be cancelled anymore for now.
The stuff is on my Maven-Repo:
Group-ID and Version for all ADBCJ projects:
That’s it for now =)
- Google Guava Collection Test Suite
- ADBCJ in Scala: Getting Started