Sha256: 19a27a86f145dbdedec106c628ce5c4f527954e909fd2c40a7a8b842441f60dc
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
require 'fileutils' require 'arjdbc' JNDI_CONFIG = { :adapter => "jdbc", :jndi => 'jdbc/derbydb' } # To test JNDI, grab fscontext-1_2-beta3.zip from # http://java.sun.com/products/jndi/downloads/index.html # and put fscontext.jar and providerutil.jar in test/ require 'test/fscontext.jar' require 'test/providerutil.jar' require 'jdbc/derby' System = java.lang.System Context = javax.naming.Context InitialContext = javax.naming.InitialContext Reference = javax.naming.Reference StringRefAddr = javax.naming.StringRefAddr System.set_property(Context::INITIAL_CONTEXT_FACTORY, 'com.sun.jndi.fscontext.RefFSContextFactory') project_path = File.expand_path(File.dirname(__FILE__) + '/../..') jndi_dir = project_path + '/jndi_test' jdbc_dir = jndi_dir + '/jdbc' FileUtils.mkdir_p jdbc_dir unless File.exist?(jdbc_dir) System.set_property(Context::PROVIDER_URL, "file://#{jndi_dir}") ic = InitialContext.new ic.rebind(JNDI_CONFIG[:jndi], org.apache.derby.jdbc.EmbeddedDataSource.new.tap {|ds| ds.database_name = "derby-testdb" ds.create_database = "create" ds.user = "sa" ds.password = ""}) ActiveRecord::Base.establish_connection(JNDI_CONFIG)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activerecord-jdbc-adapter-1.0.0.beta2-java | test/db/jndi_config.rb |