InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Ruby Driver for HSQLDB Released

Posted by Obie Fernandez on Oct 11, 2006

Sections
Architecture & Design,
Development,
Operations & Infrastructure
Topics
Interop ,
Ruby ,
Data Access
Tags
Hypersonic DB ,
SQLite ,
Database

A Ruby driver for HSQLDB has been released on RubyForge by Jared Richardson, one of the authors of the Pragmatic Programmer book Ship it! A Practical Guide to Successful Software Projects. Jared is also an article contributor to InfoQ.com, most recently writing about dealing with legacy code. This is Jared's second Ruby database driver. The first was for Ingres, but hasn't been released by CA yet.

The driver uses the Yet Another Java Bridge project to access Java objects from within Ruby, which is a very different approach to Java-Ruby interaction as that of JRuby, which gives you Ruby objects inside of Java. I asked Jared to comment on the YAJB project:

I'm not sure about the performance. I've only used in a testing situation, but I've not noticed any performance impact. But again, I haven't attempted to put it under any type of load. The YAJB project serializes the information over a socket, so it's going to be the slowest available option. But given the small amount of data that a Rails app is usually moving, I thought it was a safe bet. It was also extremely easy to get up and running.

HSQLDB, which used to be known as HypersonicSQL, is described as the leading SQL relational database engine written in Java. It has a JDBC driver and supports a rich subset of ANSI-92 SQL. Quite similar to SQLite, it has a fast database engine which offers both in-memory and disk-based tables and supports embedded and server modes.

You can install the driver easily as a RubyGem by typing gem install hypersonic, which will pull the project files off of RubyForge and install them locally. The binary distribution consists of the hsqldb.jar and a 225-line Ruby file named Hypersonic.rb. Grab the source distribution zip from the project site to get a rakefile and functional test that allows easy testing of your setup.

The following code sample illustrates use of the driver:

@h = Hypersonic.new
@h.connect("jdbc:hsqldb:file:testdb2", "sa", "")
@h.execute_update("DROP TABLE #{@temp_table_name} IF EXISTS")
@h.execute_update("CREATE TABLE #{@temp_table_name} (c1 INTEGER, c2 VARCHAR)")
@h.execute_update("INSERT INTO #{@temp_table_name}(c1, c2) VALUES (32, 'howdy')")
rs = @h.execute_query("SELECT * FROM #{@temp_table_name}")
rs = @h.execute_query("SELECT COUNT(*) FROM #{@temp_table_name}")
 

I also asked Jared to comment on plans to integrate his driver with ActiveRecord, and he said:

ActiveRecord integration is about a quarter of the way done and the client has shifted priorities... that is to say, they're not paying me to finish the AR portion at this time. :) So the AR integration is on hold at the moment. If anyone else wanted to pick it, I'd be glad to share the work I've done though. Of if someone wanted to contract with me to complete the work, I'd be willing to work on it. Right now I just don't have the time to complete it in my evenings and weekends.
HSQLDB using ActiveRecord-JDBC for JRuby by Nick Sieger Posted
  1. Back to top

    HSQLDB using ActiveRecord-JDBC for JRuby

    by Nick Sieger

    Note that ActiveRecord-JDBC (which is an JRuby/ActiveRecord driver for multiple JDBC databases) supports HSQLDB also. If you're willing to go the JRuby route, we'd be interested to hear your experiences with it on the jruby-extras mailing list.

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.