require 'java'
include_class "java.sql.Connection"
include_class "java.sql.DriverManager"
include_class "java.sql.ResultSet"
include_class "java.sql.Statement"
driver = org.apache.derby.jdbc.EmbeddedDriver.new()
conn = DriverManager.getConnection("jdbc:derby:derbyDB;create=true")
conn.setAutoCommit(false)
s = conn.createStatement()
Some of the things that tripped me up, as I was trying to convert the simple Java example to JRuby:
- The Class.forName(driver).newInstance() nonsense, I guess I've never run across this convention before but probably not surprising since I'm not a Java developer
- org.apache.derby.impl.jdbc.EmbedSQLException: Derby system shutdown - yes you should do a DriverManager.getConnection("jdbc:derby:;shutdown=true") and yes it apparently always throws an exception
- Getting useful results sets back is where I spent most of my time. Fortunately Derby documentation (like most Apache projects) are among of the best of any, whether commercial or Open Source APIs.
1 comment:
A similar set of instructions are also posted at: http://blogs.sun.com/arungupta/entry/totd_3_using_javadb_with
Post a Comment