This post originated from an RSS feed registered with Agile Buzz
by Jared Richardson.
Original Post: A Ruby Wrapper for the Hypersonic Database
Feed Title: Jared's Weblog
Feed URL: http://www.jaredrichardson.net/blog/index.rss
Feed Description: Jared's weblog.
The web site was created after the launch of the book "Ship It!" and discusses issues from Continuous Integration to web hosting providers.
I've just released an open source Ruby wrapper for Hypersonic. I wrapped the Java code with the Yet Another Java Bridge project. You could copy this project to learn how to access your legacy Java code from Ruby.
Why was the code open sourced? I had a client who wanted to use Hypersonic from Rails and they asked us to open source both the driver and ActiveRecord code. This driver was the first step. The Rails part would've used the driver in this project, but the client priorities changed, so the Rails part isn't being finished right now.
Why would someone pay for development work and then open source it? I can think of a few practical reasons.
First, I wouldn't open source my core expertise. I'd open source support tools and this fits that description for this client.
But more importantly, if the product gets other users outside of their company, my client will probably get bug fixes and new features for free. They won't have to fund every single change. Someone else might want feature X enough to pay their people to add it. In the end, all the companies and users involved get a better product and no single company or user had to bear the entire cost.
Pretty smart if you ask me. Open sourcing a tool like this is a very practical thing for a company to do.
But back to the driver.... The driver is pretty simple to use, but if you have any problems, please pass them on and I'll try to get them fixed in a timely manner. I do have a newer version of the driver with more code to support ActiveRecord/Rails metadata requests, but I wanted to release the minimal version for now. When I have time I'll try to get the AR code support into the next release.
This is my first Hypersonic project of any type, so the code hasn't been tested beyond the bundled tests and examples. Feel free to offer improvements and suggestions.
----------------------------------------
README.TXT
--------------------------------------
This is a driver (or bridge) to allow your Ruby code to use the Hypersonic database.
There are two things you need to do before you can use this driver.
First, you must have the Yet Another Java Bridge installed. http://www.cmt.phys.kyushu-u.ac.jp/~M.Sakurai/cgi-bin/fw/wiki.cgi?page=YAJB
Second, you must have hsqldb.jar in your classpath.
If you can run "rake test", then you're environment is probably fine. Just be sure that the user account you'll be running the driver under also has their classpath set up properly.
To build and install, type "rake gem", then "gem install hypersonic-1.0.gem" or "sudo gem install hypersonic-1.0.gem". You may need to insert a newer version number than 1.0
You can extract examples from the test folder. The Test_hypersonic.rb file will show you exactly how to use the driver, but here's a short
example as well. It's extracted from the test folder.
@temp_table_name = "TEMP_TABLE_FOR_THESE_TESTS"
@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}")
Please let me know if you have problems running the driver.
Jared
http://jaredrichardson.net