boiling memoir

journey of one man

Sure Way to Dump DB Schema Into Ruby Using Jdbc :)

You need:

  • jruby
  • rails (or just active record) gem
  • activerecord-jdbc-adapter

If you are using the base jdbc adapter then you need to put jdbc jar in jruby’s classpath. I just copied the jar into $JRUBY_HOME/lib

Then

  1. establish AR connection

  2. use schema dumper

e.g.

require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
  :adapter  => "jdbc",
  :driver => 'com.ibm.as400.access.AS400JDBCDriver',
  :url => 'jdbc:as400://hostname',
  :username => "blah",
  :password => "secret"
)
ActiveRecord::SchemaDumper.dump