Thursday, March 19, 2009

Introducing Drizzle JDBC

The last couple of months I've been working on a JDBC driver for Drizzle, the driver is available here. The aim for the driver was to be lightweight and easy to develop. It is likely that Connector/J will support drizzle in the future, so the aim for this driver is to be a lightweight BSD-licensed alternative.

To build the driver, do the following (java 6 is required):

$ bzr branch lp:drizzle-jdbc
$ mvn compile

If you want to package the driver into something usable, you need to have a drizzle server on your localhost with a database called test_units_jdbc, then you can do:

$ mvn package

And you will get a .jar file in the target directory. There are also nightly builds available in hudson.

The only current dependency is slf4j, so you need to put the api-jar and one of the implementations on the classpath, check here for more help. The reason I use slf4j is that i don't want to impose a logging mechanism on the users, and I dont want to build something that scans the classpath for known logging implementations etc.

Below is an example of how to use it:

Connection connection = DriverManager.getConnection("jdbc:drizzle://localhost:4427/test_units_jdbc");
Statement statement = connection.createStatement();
statement.executeUpdate("INSERT INTO t1 (id) values (1)");

The connection string is on the form:

Notes about using this driver:
  • It is under heavy development and many features expected from a JDBC driver are not yet implemented. Of course, since it is very early in the development, there will be bugs!
  • Currently only Java6 is supported (JDBC4 was released with java6)
  • The internal protocols and API's will change when the new asynchronous server-API is available. This improve performance in the driver alot
  • Authentication is not supported, this is due to the fact that drizzle does not do this out-of-the-box and the way of doing the authentication is likely to change when the new protocol is in place
  • The driver reads back the full result set into memory and there is currently no way of not doing this.
  • Prepared statements are
  • It does work with hibernate and hibernate-jpa
  • It can be set up as a datasource in JBoss
  • It could, in theory, be used against MySQL as well
  • Bug reports / feature requests are needed! Also, if anyone is interrested in contributing, please do so, contact me on IRC for example, freenode, #drizzle, my nick is marcuse

No comments: