Sha256: c1272cf4a32cb6cbb1e02bd92afc4185072ca67297e3b84f27954cce7677e6e6

Contents?: true

Size: 1.16 KB

Versions: 29

Compression:

Stored size: 1.16 KB

Contents

require 'fileutils'
require 'active_record/connection_adapters/jdbc_adapter'

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}")
derby_ref = Reference.new('javax.sql.DataSource',
                          'org.apache.commons.dbcp.BasicDataSourceFactory',
                          nil)
derby_ref.add StringRefAddr.new('driverClassName', 
                                'org.apache.derby.jdbc.EmbeddedDriver')
derby_ref.add StringRefAddr.new('url', 
                                'jdbc:derby:derby-testdb;create=true')
derby_ref.add StringRefAddr.new('username', 'sa')
derby_ref.add StringRefAddr.new('password', '')

ic = InitialContext.new
ic.rebind("jdbc/derbydb", derby_ref)

Version data entries

29 entries across 29 versions & 5 rubygems

Version Path
saturnflyer-activerecord-jdbc-adapter-0.9.3 test/db/jndi_config.rb
kb-activerecord-jdbc-adapter-0.9.7.1-java test/db/jndi_config.rb
activerecord-jdbc-adapter-0.9.7-java test/db/jndi_config.rb
activerecord-jdbc-adapter-0.9.6-java test/db/jndi_config.rb
activerecord-jdbc-adapter-0.9.5-java test/db/jndi_config.rb
activerecord-jdbc-adapter-0.9.4-java test/db/jndi_config.rb
activerecord-jdbc-adapter-0.9.3-java test/db/jndi_config.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.6 test/db/jndi_config.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.5 test/db/jndi_config.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.4 test/db/jndi_config.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.3 test/db/jndi_config.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.2 test/db/jndi_config.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.1 test/db/jndi_config.rb
activerecord-jdbc-adapter-0.9.0.1 test/db/jndi_config.rb
activerecord-jdbc-adapter-0.9.2 test/db/jndi_config.rb
ActiveRecord-JDBC-0.2.4 test/db/jndi_config.rb
ActiveRecord-JDBC-0.3 test/db/jndi_config.rb
ActiveRecord-JDBC-0.3.1 test/db/jndi_config.rb
ActiveRecord-JDBC-0.4 test/db/jndi_config.rb
ActiveRecord-JDBC-0.5 test/db/jndi_config.rb