activerecord-jdbc-adapter 0.9.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/History.txt +248 -0
  2. data/LICENSE.txt +21 -0
  3. data/Manifest.txt +125 -0
  4. data/README.txt +218 -0
  5. data/Rakefile +10 -0
  6. data/lib/active_record/connection_adapters/cachedb_adapter.rb +1 -0
  7. data/lib/active_record/connection_adapters/derby_adapter.rb +13 -0
  8. data/lib/active_record/connection_adapters/h2_adapter.rb +13 -0
  9. data/lib/active_record/connection_adapters/hsqldb_adapter.rb +13 -0
  10. data/lib/active_record/connection_adapters/informix_adapter.rb +1 -0
  11. data/lib/active_record/connection_adapters/jdbc_adapter.rb +640 -0
  12. data/lib/active_record/connection_adapters/jdbc_adapter_spec.rb +26 -0
  13. data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -0
  14. data/lib/active_record/connection_adapters/mysql_adapter.rb +13 -0
  15. data/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
  16. data/lib/active_record/connection_adapters/postgresql_adapter.rb +13 -0
  17. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +13 -0
  18. data/lib/generators/jdbc/jdbc_generator.rb +9 -0
  19. data/lib/jdbc_adapter.rb +27 -0
  20. data/lib/jdbc_adapter/jdbc.rake +121 -0
  21. data/lib/jdbc_adapter/jdbc_adapter_internal.jar +0 -0
  22. data/lib/jdbc_adapter/jdbc_cachedb.rb +33 -0
  23. data/lib/jdbc_adapter/jdbc_db2.rb +203 -0
  24. data/lib/jdbc_adapter/jdbc_derby.rb +430 -0
  25. data/lib/jdbc_adapter/jdbc_firebird.rb +109 -0
  26. data/lib/jdbc_adapter/jdbc_hsqldb.rb +218 -0
  27. data/lib/jdbc_adapter/jdbc_informix.rb +147 -0
  28. data/lib/jdbc_adapter/jdbc_mimer.rb +141 -0
  29. data/lib/jdbc_adapter/jdbc_mssql.rb +337 -0
  30. data/lib/jdbc_adapter/jdbc_mysql.rb +236 -0
  31. data/lib/jdbc_adapter/jdbc_oracle.rb +377 -0
  32. data/lib/jdbc_adapter/jdbc_postgre.rb +498 -0
  33. data/lib/jdbc_adapter/jdbc_sqlite3.rb +384 -0
  34. data/lib/jdbc_adapter/jdbc_sybase.rb +50 -0
  35. data/lib/jdbc_adapter/missing_functionality_helper.rb +87 -0
  36. data/lib/jdbc_adapter/rake_tasks.rb +10 -0
  37. data/lib/jdbc_adapter/tsql_helper.rb +60 -0
  38. data/lib/jdbc_adapter/version.rb +5 -0
  39. data/lib/pg.rb +4 -0
  40. data/rails_generators/jdbc_generator.rb +15 -0
  41. data/rails_generators/templates/config/initializers/jdbc.rb +7 -0
  42. data/rails_generators/templates/lib/tasks/jdbc.rake +8 -0
  43. data/rakelib/compile.rake +23 -0
  44. data/rakelib/package.rake +90 -0
  45. data/rakelib/rails.rake +41 -0
  46. data/rakelib/test.rake +76 -0
  47. data/src/java/jdbc_adapter/JdbcAdapterInternalService.java +53 -0
  48. data/src/java/jdbc_adapter/JdbcConnectionFactory.java +36 -0
  49. data/src/java/jdbc_adapter/JdbcDerbySpec.java +293 -0
  50. data/src/java/jdbc_adapter/JdbcMySQLSpec.java +134 -0
  51. data/src/java/jdbc_adapter/MssqlRubyJdbcConnection.java +71 -0
  52. data/src/java/jdbc_adapter/PostgresRubyJdbcConnection.java +55 -0
  53. data/src/java/jdbc_adapter/RubyJdbcConnection.java +1162 -0
  54. data/src/java/jdbc_adapter/SQLBlock.java +27 -0
  55. data/src/java/jdbc_adapter/Sqlite3RubyJdbcConnection.java +41 -0
  56. data/test/abstract_db_create.rb +107 -0
  57. data/test/activerecord/connection_adapters/type_conversion_test.rb +31 -0
  58. data/test/activerecord/connections/native_jdbc_mysql/connection.rb +25 -0
  59. data/test/cachedb_simple_test.rb +6 -0
  60. data/test/db/cachedb.rb +9 -0
  61. data/test/db/db2.rb +9 -0
  62. data/test/db/derby.rb +14 -0
  63. data/test/db/h2.rb +11 -0
  64. data/test/db/hsqldb.rb +12 -0
  65. data/test/db/informix.rb +11 -0
  66. data/test/db/jdbc.rb +11 -0
  67. data/test/db/jndi_config.rb +30 -0
  68. data/test/db/logger.rb +3 -0
  69. data/test/db/mssql.rb +9 -0
  70. data/test/db/mysql.rb +10 -0
  71. data/test/db/oracle.rb +34 -0
  72. data/test/db/postgres.rb +9 -0
  73. data/test/db/sqlite3.rb +15 -0
  74. data/test/db2_simple_test.rb +10 -0
  75. data/test/derby_migration_test.rb +21 -0
  76. data/test/derby_multibyte_test.rb +12 -0
  77. data/test/derby_simple_test.rb +21 -0
  78. data/test/generic_jdbc_connection_test.rb +9 -0
  79. data/test/h2_simple_test.rb +6 -0
  80. data/test/has_many_through.rb +79 -0
  81. data/test/helper.rb +5 -0
  82. data/test/hsqldb_simple_test.rb +6 -0
  83. data/test/informix_simple_test.rb +48 -0
  84. data/test/jdbc_adapter/jdbc_db2_test.rb +26 -0
  85. data/test/jdbc_adapter/jdbc_sybase_test.rb +33 -0
  86. data/test/jdbc_common.rb +25 -0
  87. data/test/jndi_callbacks_test.rb +38 -0
  88. data/test/jndi_test.rb +35 -0
  89. data/test/manualTestDatabase.rb +191 -0
  90. data/test/minirunit.rb +109 -0
  91. data/test/minirunit/testConnect.rb +14 -0
  92. data/test/minirunit/testH2.rb +73 -0
  93. data/test/minirunit/testHsqldb.rb +73 -0
  94. data/test/minirunit/testLoadActiveRecord.rb +3 -0
  95. data/test/minirunit/testMysql.rb +83 -0
  96. data/test/minirunit/testRawSelect.rb +24 -0
  97. data/test/models/add_not_null_column_to_table.rb +12 -0
  98. data/test/models/auto_id.rb +18 -0
  99. data/test/models/data_types.rb +28 -0
  100. data/test/models/entry.rb +23 -0
  101. data/test/models/mixed_case.rb +20 -0
  102. data/test/models/reserved_word.rb +18 -0
  103. data/test/models/string_id.rb +18 -0
  104. data/test/models/validates_uniqueness_of_string.rb +19 -0
  105. data/test/mssql_simple_test.rb +6 -0
  106. data/test/mysql_db_create_test.rb +25 -0
  107. data/test/mysql_multibyte_test.rb +10 -0
  108. data/test/mysql_nonstandard_primary_key_test.rb +42 -0
  109. data/test/mysql_simple_test.rb +32 -0
  110. data/test/oracle_simple_test.rb +29 -0
  111. data/test/pick_rails_version.rb +3 -0
  112. data/test/postgres_db_create_test.rb +21 -0
  113. data/test/postgres_mixed_case_test.rb +19 -0
  114. data/test/postgres_nonseq_pkey_test.rb +40 -0
  115. data/test/postgres_reserved_test.rb +22 -0
  116. data/test/postgres_schema_search_path_test.rb +46 -0
  117. data/test/postgres_simple_test.rb +13 -0
  118. data/test/simple.rb +475 -0
  119. data/test/sqlite3_simple_test.rb +233 -0
  120. data/test/sybase_jtds_simple_test.rb +6 -0
  121. metadata +188 -0
@@ -0,0 +1,27 @@
1
+ /*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+ package jdbc_adapter;
7
+
8
+ import java.sql.Connection;
9
+ import java.sql.ResultSet;
10
+ import java.sql.SQLException;
11
+ import java.sql.Statement;
12
+
13
+ /**
14
+ *
15
+ * @author nicksieger
16
+ */
17
+ public abstract class SQLBlock {
18
+ abstract Object call(Connection c) throws SQLException;
19
+
20
+ public void close(Statement statement) {
21
+ RubyJdbcConnection.close(statement);
22
+ }
23
+
24
+ public void close(ResultSet resultSet) {
25
+ RubyJdbcConnection.close(resultSet);
26
+ }
27
+ }
@@ -0,0 +1,41 @@
1
+ /*
2
+ * To change this template, choose Tools | Templates
3
+ * and open the template in the editor.
4
+ */
5
+
6
+ package jdbc_adapter;
7
+
8
+ import org.jruby.Ruby;
9
+ import org.jruby.RubyClass;
10
+ import org.jruby.runtime.ObjectAllocator;
11
+ import org.jruby.runtime.ThreadContext;
12
+ import org.jruby.runtime.builtin.IRubyObject;
13
+
14
+ /**
15
+ *
16
+ * @author enebo
17
+ */
18
+ public class Sqlite3RubyJdbcConnection extends RubyJdbcConnection {
19
+ protected Sqlite3RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
20
+ super(runtime, metaClass);
21
+ }
22
+
23
+ public static RubyClass createSqlite3JdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
24
+ RubyClass clazz = RubyJdbcConnection.getConnectionAdapters(runtime).defineClassUnder("Sqlite3JdbcConnection",
25
+ jdbcConnection, SQLITE3_JDBCCONNECTION_ALLOCATOR);
26
+ clazz.defineAnnotatedMethods(Sqlite3RubyJdbcConnection.class);
27
+
28
+ return clazz;
29
+ }
30
+
31
+ private static ObjectAllocator SQLITE3_JDBCCONNECTION_ALLOCATOR = new ObjectAllocator() {
32
+ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
33
+ return new Sqlite3RubyJdbcConnection(runtime, klass);
34
+ }
35
+ };
36
+
37
+ @Override
38
+ protected IRubyObject tables(ThreadContext context, String catalog, String schemaPattern, String tablePattern, String[] types) {
39
+ return (IRubyObject) withConnectionAndRetry(context, tableLookupBlock(context.getRuntime(), catalog, schemaPattern, tablePattern, types, true));
40
+ }
41
+ }
@@ -0,0 +1,107 @@
1
+ require 'jdbc_common'
2
+ require 'rake'
3
+
4
+ module Rails
5
+ class Configuration
6
+ end
7
+ class Application
8
+ def self.config
9
+ @config ||= Object.new
10
+ end
11
+ end
12
+ end
13
+
14
+ module AbstractDbCreate
15
+ def setup
16
+ @prevapp = Rake.application
17
+ Rake.application = Rake::Application.new
18
+ verbose(true)
19
+ @prevconfigs = ActiveRecord::Base.configurations
20
+ ActiveRecord::Base.connection.disconnect!
21
+ @db_name = 'test_rake_db_create'
22
+ setup_rails
23
+ set_rails_constant("env", "unittest")
24
+ set_rails_constant("root", ".")
25
+ load File.dirname(__FILE__) + '/../lib/jdbc_adapter/jdbc.rake' if jruby?
26
+ task :environment do
27
+ ActiveRecord::Base.configurations = configurations
28
+ end
29
+ task :rails_env
30
+ end
31
+
32
+ def teardown
33
+ Rake::Task["db:drop"].invoke
34
+ Rake.application = @prevapp
35
+ restore_rails
36
+ ActiveRecord::Base.configurations = @prevconfigs
37
+ ActiveRecord::Base.establish_connection(db_config)
38
+ end
39
+
40
+ def setup_rails
41
+ if ActiveRecord::VERSION::MAJOR == 3
42
+ setup_rails3
43
+ else
44
+ setup_rails2
45
+ end
46
+ end
47
+
48
+ def configurations
49
+ the_db_name = @db_name
50
+ the_db_config = db_config
51
+ @configs = { "unittest" => the_db_config.merge({:database => the_db_name}).stringify_keys! }
52
+ end
53
+
54
+ def setup_rails2
55
+ configs = configurations
56
+ Rails::Configuration.class_eval do
57
+ define_method(:database_configuration) { configs }
58
+ end
59
+ ar_version = $LOADED_FEATURES.grep(%r{active_record/version}).first
60
+ ar_lib_path = $LOAD_PATH.detect {|p| p if File.exist?File.join(p, ar_version)}
61
+ ar_lib_path = ar_lib_path.sub(%r{activerecord/lib}, 'railties/lib') # edge rails
62
+ rails_lib_path = ar_lib_path.sub(/activerecord/, 'rails') # gem rails
63
+ load "#{rails_lib_path}/tasks/databases.rake"
64
+ end
65
+
66
+ def setup_rails3
67
+ configs = configurations
68
+ (class << Rails::Application.config; self ; end).instance_eval do
69
+ define_method(:database_configuration) { configs }
70
+ end
71
+ ar_version = $LOADED_FEATURES.grep(%r{active_record/version}).first
72
+ ar_lib_path = $LOAD_PATH.detect {|p| p if File.exist?File.join(p, ar_version)}
73
+ load "#{ar_lib_path}/active_record/railties/databases.rake"
74
+ end
75
+
76
+ def set_rails_constant(name, value)
77
+ cname ="RAILS_#{name.upcase}"
78
+ @constants ||= {}
79
+ @constants[name] = Object.const_get(cname) rescue nil
80
+ silence_warnings { Object.const_set(cname, value) }
81
+ Rails.instance_eval do
82
+ if instance_methods(false).include?(name)
83
+ alias_method "orig_#{name}", name
84
+ define_method(name) { value }
85
+ end
86
+ end
87
+ end
88
+
89
+ def restore_rails
90
+ @constants.each do |key,value|
91
+ silence_warnings { Object.const_set("RAILS_#{key.upcase}", value) }
92
+ Rails.instance_eval do
93
+ if instance_methods(false).include?(name)
94
+ remove_method name
95
+ alias_method name, "orig_#{name}"
96
+ end
97
+ end
98
+ end
99
+ end
100
+
101
+ def silence_warnings
102
+ prev, $VERBOSE = $VERBOSE, nil
103
+ yield
104
+ ensure
105
+ $VERBOSE = prev
106
+ end
107
+ end
@@ -0,0 +1,31 @@
1
+ require 'java'
2
+ require 'models/data_types'
3
+ require 'active_record/connection_adapters/jdbc_adapter'
4
+ require 'db/derby'
5
+ require 'test/unit'
6
+
7
+ JInteger = java.lang.Integer
8
+
9
+ class TypeConversionTest < Test::Unit::TestCase
10
+ TEST_TIME = Time.at(1169964202).gmtime
11
+ def setup
12
+ DbTypeMigration.up
13
+ DbType.create(
14
+ :sample_timestamp => TEST_TIME,
15
+ :sample_decimal => JInteger::MAX_VALUE + 1)
16
+ end
17
+
18
+ def teardown
19
+ DbTypeMigration.down
20
+ end
21
+
22
+ def test_timestamp
23
+ types = DbType.find(:first)
24
+ assert_equal TEST_TIME, types.sample_timestamp.getutc
25
+ end
26
+
27
+ def test_decimal
28
+ types = DbType.find(:first)
29
+ assert_equal((JInteger::MAX_VALUE + 1), types.sample_decimal)
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ print "Using native JDBC (MySQL)\n"
2
+ require_dependency 'fixtures/course'
3
+ require 'logger'
4
+
5
+ RAILS_CONNECTION_ADAPTERS << 'jdbc'
6
+ require "active_record/connection_adapters/jdbc_adapter"
7
+
8
+ ActiveRecord::Base.logger = Logger.new("debug.log")
9
+
10
+ db1 = 'activerecord_unittest'
11
+ db2 = 'activerecord_unittest2'
12
+
13
+ ActiveRecord::Base.establish_connection(
14
+ :adapter => "jdbc",
15
+ :driver => "com.mysql.jdbc.Driver",
16
+ :url => "jdbc:mysql://localhost:3306/#{db1}",
17
+ :username => "rails"
18
+ )
19
+
20
+ Course.establish_connection(
21
+ :adapter => "jdbc",
22
+ :driver => "com.mysql.jdbc.Driver",
23
+ :url => "jdbc:mysql://localhost:3306/#{db2}",
24
+ :username => "rails"
25
+ )
@@ -0,0 +1,6 @@
1
+ require 'jdbc_common'
2
+ require 'db/cachedb'
3
+
4
+ class CacheDBSimpleTest < Test::Unit::TestCase
5
+ include SimpleTestMethods
6
+ end
@@ -0,0 +1,9 @@
1
+ config = {
2
+ :username => '_SYSTEM',
3
+ :password => 'SYS',
4
+ :adapter => 'cachedb',
5
+ :host => ENV[ "CACHE_HOST" ] || 'localhost',
6
+ :database => ENV[ "CACHE_NAMESPACE" ] || 'weblog_development'
7
+ }
8
+
9
+ ActiveRecord::Base.establish_connection( config )
@@ -0,0 +1,9 @@
1
+ config = {
2
+ :username => "blog",
3
+ :password => "",
4
+ :adapter => "jdbc",
5
+ :driver => "com.ibm.db2.jcc.DB2Driver",
6
+ :url => "jdbc:db2:weblog_development"
7
+ }
8
+
9
+ ActiveRecord::Base.establish_connection(config)
@@ -0,0 +1,14 @@
1
+ require 'logger'
2
+
3
+ config = {
4
+ :adapter => 'derby',
5
+ :database => "derby-testdb"
6
+ }
7
+
8
+ ActiveRecord::Base.establish_connection(config)
9
+
10
+ at_exit {
11
+ # Clean up derby files
12
+ require 'fileutils'
13
+ FileUtils.rm_rf('derby-testdb')
14
+ }
@@ -0,0 +1,11 @@
1
+ config = {
2
+ :adapter => 'h2',
3
+ :database => 'test.db'
4
+ }
5
+
6
+ ActiveRecord::Base.establish_connection(config)
7
+
8
+ at_exit {
9
+ # Clean up hsqldb when done
10
+ Dir['test.db*'].each {|f| File.delete(f)}
11
+ }
@@ -0,0 +1,12 @@
1
+ config = {
2
+ :adapter => 'hsqldb',
3
+ :database => 'test.db'
4
+ }
5
+
6
+ ActiveRecord::Base.establish_connection(config)
7
+
8
+ at_exit {
9
+ # Clean up hsqldb when done
10
+ Dir['test.db*'].each {|f| File.delete(f)}
11
+ File.delete('hsqldb-testdb.log') rescue nil #can't delete on windows
12
+ }
@@ -0,0 +1,11 @@
1
+ config = {
2
+ :username => 'blog',
3
+ :password => 'blog',
4
+ :adapter => 'informix',
5
+ :servername => 'ol_weblog',
6
+ :database => 'weblog_development',
7
+ :host => 'localhost',
8
+ :port => '9088'
9
+ }
10
+
11
+ ActiveRecord::Base.establish_connection(config)
@@ -0,0 +1,11 @@
1
+ require 'jdbc/mysql'
2
+
3
+ config = {
4
+ :username => 'blog',
5
+ :password => '',
6
+ :adapter => 'jdbc',
7
+ :driver => 'com.mysql.jdbc.Driver',
8
+ :url => 'jdbc:mysql://localhost:3306/weblog_development'
9
+ }
10
+
11
+ ActiveRecord::Base.establish_connection(config)
@@ -0,0 +1,30 @@
1
+ require 'fileutils'
2
+ require 'active_record/connection_adapters/jdbc_adapter'
3
+
4
+ System = java.lang.System
5
+ Context = javax.naming.Context
6
+ InitialContext = javax.naming.InitialContext
7
+ Reference = javax.naming.Reference
8
+ StringRefAddr = javax.naming.StringRefAddr
9
+
10
+ System.set_property(Context::INITIAL_CONTEXT_FACTORY,
11
+ 'com.sun.jndi.fscontext.RefFSContextFactory')
12
+ project_path = File.expand_path(File.dirname(__FILE__) + '/../..')
13
+ jndi_dir = project_path + '/jndi_test'
14
+ jdbc_dir = jndi_dir + '/jdbc'
15
+ FileUtils.mkdir_p jdbc_dir unless File.exist?(jdbc_dir)
16
+
17
+ System.set_property(Context::PROVIDER_URL, "file://#{jndi_dir}")
18
+ derby_ref = Reference.new('javax.sql.DataSource',
19
+ 'org.apache.commons.dbcp.BasicDataSourceFactory',
20
+ nil)
21
+ derby_ref.add StringRefAddr.new('driverClassName',
22
+ 'org.apache.derby.jdbc.EmbeddedDriver')
23
+ derby_ref.add StringRefAddr.new('url',
24
+ 'jdbc:derby:derby-testdb;create=true')
25
+ derby_ref.add StringRefAddr.new('username', 'sa')
26
+ derby_ref.add StringRefAddr.new('password', '')
27
+
28
+ ic = InitialContext.new
29
+ ic.rebind("jdbc/derbydb", derby_ref)
30
+
@@ -0,0 +1,3 @@
1
+ require 'logger'
2
+ ActiveRecord::Base.logger = Logger.new($stdout)
3
+ ActiveRecord::Base.logger.level = Logger::DEBUG
@@ -0,0 +1,9 @@
1
+ config = {
2
+ :username => 'blog',
3
+ :password => '',
4
+ :adapter => 'jdbc',
5
+ :url => "jdbc:jtds:sqlserver://localhost:1433/weblog_development",
6
+ :driver => 'net.sourceforge.jtds.jdbc.Driver'
7
+ }
8
+
9
+ ActiveRecord::Base.establish_connection( config )
@@ -0,0 +1,10 @@
1
+ MYSQL_CONFIG = {
2
+ :username => 'blog',
3
+ :password => '',
4
+ :adapter => 'mysql',
5
+ :database => 'weblog_development',
6
+ :host => 'localhost'
7
+ }
8
+
9
+ ActiveRecord::Base.establish_connection(MYSQL_CONFIG)
10
+
@@ -0,0 +1,34 @@
1
+ config = {
2
+ :username => 'blog',
3
+ :password => 'blog',
4
+ :adapter => 'oracle',
5
+ :host => ENV["ORACLE_HOST"] || 'localhost',
6
+ :database => ENV["ORACLE_SID"] || 'XE' # XE is the default SID for oracle xe
7
+ }
8
+
9
+ ActiveRecord::Base.establish_connection(config)
10
+
11
+ # Here are some notes of things I had to do to get running on Oracle
12
+ # XE.
13
+ #
14
+ # ON Linux:
15
+ # create tablespace weblog_development
16
+ # datafile '/usr/lib/oracle/xe/oradata/XE/weblog_development.dbf';
17
+ # ON Windows XP:
18
+ # create tablespace weblog_development
19
+ # datafile 'C:\ORACLEXE\ORADATA\XE\WEBLOGD.DBF' size 16m;
20
+ #
21
+ # create user blog identified by blog
22
+ # default tablespace weblog_development;
23
+ # grant all privileges to blog;
24
+ #
25
+ # You might need to up the number of processes and restart the
26
+ # listener. (In my case, I had to reboot.) See
27
+ # http://it.newinstance.it/2007/06/01/ora-12519-tnsno-appropriate-service-handler-found/
28
+ #
29
+ # alter system set PROCESSES=150 scope=SPFILE;
30
+ #
31
+ # These might be helpful too (numbers are rather arbitrary...)
32
+ #
33
+ # alter system set TRANSACTIONS=126 scope=SPFILE;
34
+ # alter system set SESSIONS=115 scope=SPFILE;
@@ -0,0 +1,9 @@
1
+ POSTGRES_CONFIG = {
2
+ :adapter => 'postgresql',
3
+ :database => 'weblog_development',
4
+ :host => 'localhost',
5
+ :username => 'blog',
6
+ :password => ''
7
+ }
8
+
9
+ ActiveRecord::Base.establish_connection(POSTGRES_CONFIG)
@@ -0,0 +1,15 @@
1
+ require 'jdbc/sqlite3' if jruby?
2
+
3
+ config = {
4
+ :adapter => jruby? ? 'jdbcsqlite3' : 'sqlite3',
5
+ :dbfile => 'test.sqlite3.db'
6
+ # :url => 'jdbc:sqlite:test.sqlite3.db',
7
+ # :driver => 'org.sqlite.JDBC'
8
+ }
9
+
10
+ ActiveRecord::Base.establish_connection(config)
11
+
12
+ at_exit {
13
+ # Clean up sqlite3 db when done
14
+ Dir['test.sqlite3*'].each {|f| File.delete(f)}
15
+ }