activerecord-jdbc-adapter-ficoh 1.3.21-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +35 -0
  3. data/.travis.yml +462 -0
  4. data/.yardopts +4 -0
  5. data/Appraisals +36 -0
  6. data/CONTRIBUTING.md +49 -0
  7. data/Gemfile +68 -0
  8. data/History.md +1191 -0
  9. data/LICENSE.txt +25 -0
  10. data/README.md +277 -0
  11. data/RUNNING_TESTS.md +88 -0
  12. data/Rakefile +298 -0
  13. data/Rakefile.jdbc +20 -0
  14. data/activerecord-jdbc-adapter.gemspec +63 -0
  15. data/lib/active_record/connection_adapters/as400_adapter.rb +2 -0
  16. data/lib/active_record/connection_adapters/db2_adapter.rb +1 -0
  17. data/lib/active_record/connection_adapters/derby_adapter.rb +1 -0
  18. data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
  19. data/lib/active_record/connection_adapters/h2_adapter.rb +1 -0
  20. data/lib/active_record/connection_adapters/hsqldb_adapter.rb +1 -0
  21. data/lib/active_record/connection_adapters/informix_adapter.rb +1 -0
  22. data/lib/active_record/connection_adapters/jdbc_adapter.rb +1 -0
  23. data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -0
  24. data/lib/active_record/connection_adapters/mariadb_adapter.rb +1 -0
  25. data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -0
  26. data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -0
  27. data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -0
  28. data/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
  29. data/lib/active_record/connection_adapters/postgresql_adapter.rb +1 -0
  30. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -0
  31. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
  32. data/lib/activerecord-jdbc-adapter.rb +1 -0
  33. data/lib/arel/visitors/compat.rb +64 -0
  34. data/lib/arel/visitors/db2.rb +137 -0
  35. data/lib/arel/visitors/derby.rb +112 -0
  36. data/lib/arel/visitors/firebird.rb +79 -0
  37. data/lib/arel/visitors/h2.rb +25 -0
  38. data/lib/arel/visitors/hsqldb.rb +32 -0
  39. data/lib/arel/visitors/postgresql_jdbc.rb +6 -0
  40. data/lib/arel/visitors/sql_server.rb +225 -0
  41. data/lib/arel/visitors/sql_server/ng42.rb +293 -0
  42. data/lib/arjdbc.rb +22 -0
  43. data/lib/arjdbc/db2.rb +4 -0
  44. data/lib/arjdbc/db2/adapter.rb +802 -0
  45. data/lib/arjdbc/db2/as400.rb +137 -0
  46. data/lib/arjdbc/db2/column.rb +177 -0
  47. data/lib/arjdbc/db2/connection_methods.rb +45 -0
  48. data/lib/arjdbc/derby.rb +3 -0
  49. data/lib/arjdbc/derby/active_record_patch.rb +13 -0
  50. data/lib/arjdbc/derby/adapter.rb +567 -0
  51. data/lib/arjdbc/derby/connection_methods.rb +16 -0
  52. data/lib/arjdbc/derby/schema_creation.rb +15 -0
  53. data/lib/arjdbc/discover.rb +104 -0
  54. data/lib/arjdbc/firebird.rb +4 -0
  55. data/lib/arjdbc/firebird/adapter.rb +468 -0
  56. data/lib/arjdbc/firebird/connection_methods.rb +20 -0
  57. data/lib/arjdbc/h2.rb +3 -0
  58. data/lib/arjdbc/h2/adapter.rb +335 -0
  59. data/lib/arjdbc/h2/connection_methods.rb +22 -0
  60. data/lib/arjdbc/hsqldb.rb +3 -0
  61. data/lib/arjdbc/hsqldb/adapter.rb +304 -0
  62. data/lib/arjdbc/hsqldb/connection_methods.rb +23 -0
  63. data/lib/arjdbc/hsqldb/explain_support.rb +35 -0
  64. data/lib/arjdbc/hsqldb/schema_creation.rb +11 -0
  65. data/lib/arjdbc/informix.rb +5 -0
  66. data/lib/arjdbc/informix/adapter.rb +160 -0
  67. data/lib/arjdbc/informix/connection_methods.rb +9 -0
  68. data/lib/arjdbc/jdbc.rb +62 -0
  69. data/lib/arjdbc/jdbc/adapter.rb +997 -0
  70. data/lib/arjdbc/jdbc/adapter_require.rb +46 -0
  71. data/lib/arjdbc/jdbc/arel_support.rb +149 -0
  72. data/lib/arjdbc/jdbc/base_ext.rb +34 -0
  73. data/lib/arjdbc/jdbc/callbacks.rb +52 -0
  74. data/lib/arjdbc/jdbc/column.rb +83 -0
  75. data/lib/arjdbc/jdbc/connection.rb +26 -0
  76. data/lib/arjdbc/jdbc/connection_methods.rb +59 -0
  77. data/lib/arjdbc/jdbc/driver.rb +44 -0
  78. data/lib/arjdbc/jdbc/error.rb +75 -0
  79. data/lib/arjdbc/jdbc/extension.rb +69 -0
  80. data/lib/arjdbc/jdbc/java.rb +13 -0
  81. data/lib/arjdbc/jdbc/type_cast.rb +154 -0
  82. data/lib/arjdbc/jdbc/type_converter.rb +142 -0
  83. data/lib/arjdbc/mssql.rb +7 -0
  84. data/lib/arjdbc/mssql/adapter.rb +822 -0
  85. data/lib/arjdbc/mssql/column.rb +207 -0
  86. data/lib/arjdbc/mssql/connection_methods.rb +72 -0
  87. data/lib/arjdbc/mssql/explain_support.rb +99 -0
  88. data/lib/arjdbc/mssql/limit_helpers.rb +231 -0
  89. data/lib/arjdbc/mssql/lock_methods.rb +77 -0
  90. data/lib/arjdbc/mssql/types.rb +343 -0
  91. data/lib/arjdbc/mssql/utils.rb +82 -0
  92. data/lib/arjdbc/mysql.rb +3 -0
  93. data/lib/arjdbc/mysql/adapter.rb +998 -0
  94. data/lib/arjdbc/mysql/bulk_change_table.rb +150 -0
  95. data/lib/arjdbc/mysql/column.rb +167 -0
  96. data/lib/arjdbc/mysql/connection_methods.rb +137 -0
  97. data/lib/arjdbc/mysql/explain_support.rb +82 -0
  98. data/lib/arjdbc/mysql/schema_creation.rb +58 -0
  99. data/lib/arjdbc/oracle.rb +4 -0
  100. data/lib/arjdbc/oracle/adapter.rb +968 -0
  101. data/lib/arjdbc/oracle/column.rb +136 -0
  102. data/lib/arjdbc/oracle/connection_methods.rb +21 -0
  103. data/lib/arjdbc/postgresql.rb +3 -0
  104. data/lib/arjdbc/postgresql/_bc_time_cast_patch.rb +21 -0
  105. data/lib/arjdbc/postgresql/adapter.rb +1498 -0
  106. data/lib/arjdbc/postgresql/base/array_parser.rb +95 -0
  107. data/lib/arjdbc/postgresql/base/oid.rb +412 -0
  108. data/lib/arjdbc/postgresql/base/pgconn.rb +8 -0
  109. data/lib/arjdbc/postgresql/base/schema_definitions.rb +132 -0
  110. data/lib/arjdbc/postgresql/column.rb +640 -0
  111. data/lib/arjdbc/postgresql/connection_methods.rb +44 -0
  112. data/lib/arjdbc/postgresql/explain_support.rb +53 -0
  113. data/lib/arjdbc/postgresql/oid/bytea.rb +3 -0
  114. data/lib/arjdbc/postgresql/oid_types.rb +265 -0
  115. data/lib/arjdbc/postgresql/schema_creation.rb +60 -0
  116. data/lib/arjdbc/railtie.rb +11 -0
  117. data/lib/arjdbc/sqlite3.rb +3 -0
  118. data/lib/arjdbc/sqlite3/adapter.rb +654 -0
  119. data/lib/arjdbc/sqlite3/connection_methods.rb +36 -0
  120. data/lib/arjdbc/sqlite3/explain_support.rb +29 -0
  121. data/lib/arjdbc/sybase.rb +2 -0
  122. data/lib/arjdbc/sybase/adapter.rb +47 -0
  123. data/lib/arjdbc/tasks.rb +13 -0
  124. data/lib/arjdbc/tasks/database_tasks.rb +66 -0
  125. data/lib/arjdbc/tasks/databases.rake +91 -0
  126. data/lib/arjdbc/tasks/databases3.rake +239 -0
  127. data/lib/arjdbc/tasks/databases4.rake +39 -0
  128. data/lib/arjdbc/tasks/db2_database_tasks.rb +104 -0
  129. data/lib/arjdbc/tasks/derby_database_tasks.rb +95 -0
  130. data/lib/arjdbc/tasks/h2_database_tasks.rb +31 -0
  131. data/lib/arjdbc/tasks/hsqldb_database_tasks.rb +70 -0
  132. data/lib/arjdbc/tasks/jdbc_database_tasks.rb +169 -0
  133. data/lib/arjdbc/tasks/mssql_database_tasks.rb +46 -0
  134. data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +297 -0
  135. data/lib/arjdbc/tasks/oracle_database_tasks.rb +65 -0
  136. data/lib/arjdbc/util/quoted_cache.rb +60 -0
  137. data/lib/arjdbc/util/serialized_attributes.rb +98 -0
  138. data/lib/arjdbc/util/table_copier.rb +108 -0
  139. data/lib/arjdbc/version.rb +8 -0
  140. data/lib/generators/jdbc/USAGE +9 -0
  141. data/lib/generators/jdbc/jdbc_generator.rb +17 -0
  142. data/pom.xml +285 -0
  143. data/rails_generators/jdbc_generator.rb +15 -0
  144. data/rails_generators/templates/config/initializers/jdbc.rb +10 -0
  145. data/rails_generators/templates/lib/tasks/jdbc.rake +11 -0
  146. data/rakelib/01-tomcat.rake +51 -0
  147. data/rakelib/02-test.rake +151 -0
  148. data/rakelib/bundler_ext.rb +11 -0
  149. data/rakelib/db.rake +58 -0
  150. data/rakelib/rails.rake +77 -0
  151. data/src/java/arjdbc/ArJdbcModule.java +288 -0
  152. data/src/java/arjdbc/db2/DB2Module.java +77 -0
  153. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +128 -0
  154. data/src/java/arjdbc/derby/DerbyModule.java +180 -0
  155. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +153 -0
  156. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +190 -0
  157. data/src/java/arjdbc/h2/H2Module.java +50 -0
  158. data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +86 -0
  159. data/src/java/arjdbc/hsqldb/HSQLDBModule.java +74 -0
  160. data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +76 -0
  161. data/src/java/arjdbc/jdbc/AdapterJavaService.java +43 -0
  162. data/src/java/arjdbc/jdbc/Callable.java +44 -0
  163. data/src/java/arjdbc/jdbc/ConnectionFactory.java +77 -0
  164. data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +156 -0
  165. data/src/java/arjdbc/jdbc/DriverConnectionFactory.java +63 -0
  166. data/src/java/arjdbc/jdbc/DriverWrapper.java +128 -0
  167. data/src/java/arjdbc/jdbc/JdbcConnectionFactory.java +32 -0
  168. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +4541 -0
  169. data/src/java/arjdbc/jdbc/SQLBlock.java +54 -0
  170. data/src/java/arjdbc/jdbc/WithResultSet.java +37 -0
  171. data/src/java/arjdbc/mssql/MSSQLModule.java +91 -0
  172. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +193 -0
  173. data/src/java/arjdbc/mysql/MySQLModule.java +140 -0
  174. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +456 -0
  175. data/src/java/arjdbc/oracle/OracleModule.java +81 -0
  176. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +477 -0
  177. data/src/java/arjdbc/postgresql/ByteaUtils.java +171 -0
  178. data/src/java/arjdbc/postgresql/DriverImplementation.java +78 -0
  179. data/src/java/arjdbc/postgresql/PGDriverImplementation.java +535 -0
  180. data/src/java/arjdbc/postgresql/PostgreSQLModule.java +189 -0
  181. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +489 -0
  182. data/src/java/arjdbc/sqlite3/SQLite3Module.java +93 -0
  183. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +405 -0
  184. data/src/java/arjdbc/util/CallResultSet.java +826 -0
  185. data/src/java/arjdbc/util/DateTimeUtils.java +517 -0
  186. data/src/java/arjdbc/util/NumberUtils.java +50 -0
  187. data/src/java/arjdbc/util/ObjectSupport.java +65 -0
  188. data/src/java/arjdbc/util/QuotingUtils.java +139 -0
  189. data/src/java/arjdbc/util/StringCache.java +60 -0
  190. data/src/java/arjdbc/util/StringHelper.java +155 -0
  191. metadata +288 -0
@@ -0,0 +1,25 @@
1
+ Copyright (c) 2012-2014 Karol Bucek <self@kares.org>
2
+ Copyright (c) 2006-2012 Nick Sieger <nick@nicksieger.com>
3
+ Copyright (c) 2006-2008 Ola Bini <ola.bini@gmail.com>
4
+
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without modification,
8
+ are permitted provided that the following conditions are met:
9
+
10
+ - Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+ - Redistributions in binary form must reproduce the above copyright notice, this
13
+ list of conditions and the following disclaimer in the documentation and/or
14
+ other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
20
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,277 @@
1
+ # ActiveRecord JDBC Adapter
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/activerecord-jdbc-adapter.png)][7]
4
+
5
+ ActiveRecord-JDBC-Adapter (AR-JDBC) is a database adapter for Rails'
6
+ *ActiveRecord* component that can be used with [JRuby][0]. It allows use of
7
+ virtually any JDBC-compliant database with your JRuby on Rails application.
8
+
9
+ We do support *ActiveRecord* **3.x** and **4.x** (also **2.3** is still expected
10
+ to work) from a single code base. AR-JDBC needs JRuby 1.7.x or 9K (we recommend
11
+ using the latest and greatest of versions) thus Java >= **1.6** is mandatory.
12
+
13
+
14
+ **This README and master targets AR-JDBC 1.4.0 (pre-release) please use the
15
+ [1-3-stable](https://github.com/jruby/activerecord-jdbc-adapter/tree/1-3-stable)
16
+ branch for current stable 1.3.x releases.**
17
+
18
+ The next release 1.4 aims to concentrate on internal refactoring and optimization.
19
+ We're going to be (slowly) dropping support for all of Rails < 3.2, unless there
20
+ is demand for these. In which case we kindly hope to receive PRs.
21
+
22
+ ## Databases
23
+
24
+ ActiveRecord-JDBC-Adapter provides (built-in) full or nearly full support for:
25
+ **MySQL** (and **MariaDB**), **PostgreSQL**, **SQLite3**, **Oracle**, **DB2**,
26
+ *MS-SQL** (SQL Server), **Firebird**, **Derby**, **HSQLDB**, **H2**, and **Informix**.
27
+
28
+ Even if you're database product is not listed, there are 3rd party gems built on
29
+ top of AR-JDBC to handle different data-sources, [search][8] at the usual places.
30
+
31
+ ## Using ActiveRecord JDBC
32
+
33
+ ### Inside Rails
34
+
35
+ To use AR-JDBC with JRuby on Rails:
36
+
37
+ 1. Choose the adapter (base is usually fine), the following are pre-packaged :
38
+
39
+ - Base JDBC (`activerecord-jdbc-adapter`) - supports all available databases
40
+ via JDBC (Java's unified DB interface), but requires you to setup a JDBC
41
+ driver (which with most open-source drivers means adding another gem to your
42
+ *Gemfile* e.g. `gem 'jdbc-mysql'` just like on MRI), for drivers not packed
43
+ as gems just add the required jars to the class-path
44
+ - MySQL (`activerecord-jdbcmysql-adapter`)
45
+ - PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
46
+ - SQLite3 (`activerecord-jdbcsqlite3-adapter`)
47
+ - Derby (`activerecord-jdbcderby-adapter`)
48
+ - HSQLDB (`activerecord-jdbchsqldb-adapter`)
49
+ - H2 (`activerecord-jdbch2-adapter`)
50
+ - MSSQL (`activerecord-jdbcmssql-adapter`) - uses the OSS jTDS driver which
51
+ might have issues with the latest SQLServer (but should work using the
52
+ Microsoft JDBC Driver for SQL Server - we recommend using version 4.0)
53
+ **NOTE:** [jTDS](http://jtds.sourceforge.net/) seems no longer maintained,
54
+ if you're run into issues consider using the official (proprietary) driver.
55
+
56
+ 2a. If you're generating a new Rails application, run the usual :
57
+
58
+ jruby -S rails new sweetapp
59
+
60
+ 2b. Otherwise, you might need to perform some extra configuration steps
61
+ to prepare your Rails application for JDBC.
62
+
63
+ You'll need to modify your *Gemfile* to use the *activerecord-jdbc-adapter* gem
64
+ (or one of the helper gems) under JRuby. Change your *Gemfile* to look something
65
+ like the following :
66
+
67
+ ```ruby
68
+ gem 'mysql2', platform: :ruby
69
+ gem 'jdbc-mysql', platform: :jruby
70
+ gem 'activerecord-jdbc-adapter', platform: :jruby
71
+ ```
72
+
73
+ 3. Configure your *database.yml* in the normal Rails style :
74
+
75
+ ```yml
76
+ development:
77
+ adapter: mysql2 # or mysql
78
+ database: blog_development
79
+ username: blog
80
+ password: 1234
81
+ ```
82
+
83
+ **Legacy Configuration:** If you use one of the *activerecord-jdbcxxx-adapter*
84
+ gems, you can still put a 'jdbc' prefix in front of the database adapter name,
85
+ e.g. `adapter: jdbcmysql` but it's no longer recommended on Rails >= 3.0
86
+
87
+ For plain JDBC database configurations, you'll need to know the database driver
88
+ class and URL (do not forget to put the driver .jar(s) on the class-path) e.g. :
89
+
90
+ ```yml
91
+ development:
92
+ adapter: jdbc
93
+ driver: org.apache.hadoop.hive.jdbc.HiveDriver
94
+ url: jdbc:hive://localhost:10004/default
95
+ ```
96
+
97
+ **NOTE:** please do not confuse the `:url` setting with the one introduced in
98
+ ActiveRecord 4.1, we've been using it for a long time with AR-JDBC and for now
99
+ should work just fine the "jdbc:xxx" way (passed to the driver directly) ...
100
+
101
+ For JNDI data sources, you may simply specify the JNDI location as follows, it's
102
+ recommended to use the same adapter: setting as one would configure when using
103
+ "bare" (JDBC) connections e.g. :
104
+
105
+ ```yml
106
+ production:
107
+ adapter: postgresql
108
+ jndi: jdbc/PostgreDS
109
+ # be aware that by default AR defaults to pool: 5
110
+ # there are (unofficial) ways of avoiding AR's pooling
111
+ # one such would be: ActiveRecord::Bogacs::FalsePool
112
+ ```
113
+
114
+ **NOTE:** any other settings such as *database:*, *username:*, *properties:* make
115
+ no difference since everything is already configured on the data source end.
116
+
117
+ Most data-sources will provide you with connection pooling, but ActiveRecord uses
118
+ an internal pool (with a default size of 5) as well, thus you need to be careful
119
+ to configure both pools wisely to handle your requirements. If you'd like to
120
+ "disable" AR's built-in pool try : https://github.com/kares/activerecord-bogacs
121
+
122
+ JDBC driver specific properties might be set if you use an URL to specify the DB
123
+ or preferably using the *properties:* syntax :
124
+
125
+ ```yml
126
+ production:
127
+ adapter: mysql
128
+ username: blog
129
+ password: blog
130
+ url: "jdbc:mysql://localhost:3306/blog?profileSQL=true"
131
+ properties: # specific to com.mysql.jdbc.Driver
132
+ socketTimeout: 60000
133
+ connectTimeout: 60000
134
+ ```
135
+
136
+ If you're really old school you might want to use AR-JDBC with a DB2 on z/OS :
137
+
138
+ ```yml
139
+ development:
140
+ adapter: db2
141
+ url: jdbc:db2j:net://mightyzoshost:446/RAILS_DBT1
142
+ schema: DB2XB12
143
+ database: RAILS_DB1
144
+ tablespace: TSDE911
145
+ lob_tablespaces:
146
+ first_table: TSDE912
147
+ username: business
148
+ password: machines
149
+ # default driver used is :
150
+ #driver: com.ibm.db2.jcc.DB2Driver
151
+ # NOTE: AS400 support is deprecated since 1.4 in favor
152
+ # of the standalone activerecord-jdbcas400-adapter gem
153
+ ```
154
+
155
+ More information on (configuring) AR-JDBC might be found on our [wiki][5].
156
+
157
+ ### Standalone with ActiveRecord
158
+
159
+ Once the setup is made (see below) you can establish a JDBC connection like this
160
+ (e.g. for `activerecord-jdbcderby-adapter`):
161
+
162
+ ```ruby
163
+ ActiveRecord::Base.establish_connection adapter: 'derby', database: 'db/my-db'
164
+ ```
165
+
166
+ #### Using Bundler
167
+
168
+ Proceed as with Rails; specify `gem 'activerecord'` in your Bundle along with the
169
+ chosen JDBC adapter (or driver), sample *Gemfile* for MySQL :
170
+
171
+ ```ruby
172
+ gem 'activerecord', '~> 3.2.18'
173
+ gem 'activerecord-jdbcmysql-adapter' # or :
174
+ # gem 'mysql2', :platform => :mri # C-driver
175
+ # gem 'activerecord-jdbc-adapter', :platform => :jruby
176
+ # gem 'jdbc-mysql', :platform => :jruby # J-driver
177
+ ```
178
+
179
+ When you `require 'bundler/setup'` everything will be set up for you as expected.
180
+
181
+ You do not need to use the 'helper' *activerecord-jdbcxxx-adapter* gem we provide
182
+ but than should make sure an appropriate JDBC driver is available at runtime, in
183
+ that case simply setup your *Gemfile* as:
184
+
185
+ ```ruby
186
+ gem 'activerecord', '~> 4.1.6'
187
+ gem 'activerecord-jdbc-adapter', '~> 1.3', platform: :jruby
188
+ # e.g. for PostgreSQL you'll probably add :
189
+ # gem 'pg', platform: :mri
190
+ # gem 'jdbc-postgres', platform: :jruby
191
+ ```
192
+
193
+ #### Without Bundler
194
+
195
+ Install the needed gems with JRuby, for example:
196
+
197
+ gem install activerecord -v "~> 3.2"
198
+ gem install activerecord-jdbc-adapter --ignore-dependencies
199
+
200
+ If you wish to use the adapter for a specific database, you can install it
201
+ directly and the (jdbc-) driver gem (dependency) will be installed as well:
202
+
203
+ jruby -S gem install activerecord-jdbcderby-adapter
204
+
205
+ Your program should include:
206
+
207
+ ```ruby
208
+ require 'active_record'
209
+ require 'activerecord-jdbc-adapter' if defined? JRUBY_VERSION
210
+ # or in case you're using the pre-packaged adapter gem :
211
+ require 'activerecord-jdbcderby-adapter' if defined? JRUBY_VERSION
212
+ ```
213
+
214
+ ## Extending AR-JDBC
215
+
216
+ You can create your own extension to AR-JDBC for a JDBC-based database that core
217
+ AR-JDBC does not support. We've created an example project for the Intersystems
218
+ Cache database that you can examine as a template.
219
+ See the [cachedb-adapter project][4] for more information.
220
+
221
+ ## Source
222
+
223
+ The source for activerecord-jdbc-adapter is available using git:
224
+
225
+ git clone git://github.com/jruby/activerecord-jdbc-adapter.git
226
+
227
+ **You will need to have JDK 7+ to compile the native JRuby extension part.**
228
+
229
+ **NOTE:** Currently, one also needs to make sure to install all of the gem's
230
+ [development dependencies][10] to make sure the compilation `javac` task does
231
+ found it's dependent (Java) classes.
232
+
233
+ Please note that the project manages multiple gems from a single repository,
234
+ if you're using *Bundler* >= 1.2 it should be able to locate all gemspecs from
235
+ the git repository. Sample *Gemfile* for running with (MySQL) master:
236
+
237
+ ```ruby
238
+ gem 'activerecord-jdbc-adapter', :github => 'jruby/activerecord-jdbc-adapter'
239
+ ```
240
+
241
+ ## Getting Involved
242
+
243
+ Please read our [CONTRIBUTING](CONTRIBUTING.md) & [RUNNING_TESTS](RUNNING_TESTS.md)
244
+ guides for starters. You can always help us by maintaining AR-JDBC's [wiki][5].
245
+
246
+ ## Feedback
247
+
248
+ Please report bugs at our [issue tracker][3]. If you're not sure if something's
249
+ a bug, feel free to pre-report it on the [mailing lists][1] or ask on the #JRuby
250
+ IRC channel on http://freenode.net/ (try [web-chat][6]).
251
+
252
+ ## Authors
253
+
254
+ This project was originally written by [Nick Sieger](http://github.com/nicksieger)
255
+ and [Ola Bini](http://github.com/olabini) with lots of help from the community.
256
+ Polished 3.x compatibility and 4.x support (since AR-JDBC >= 1.3.0) was managed by
257
+ [Karol Bucek](http://github.com/kares) among other fellow JRuby-ists.
258
+
259
+ ## License
260
+
261
+ ActiveRecord-JDBC-Adapter is open-source released under the BSD/MIT license.
262
+ See [LICENSE.txt](LICENSE.txt) included with the distribution for details.
263
+
264
+ Open-source driver gems within AR-JDBC's sources are licensed under the same
265
+ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
266
+
267
+ [0]: http://www.jruby.org/
268
+ [1]: http://jruby.org/community
269
+ [2]: http://github.com/jruby/activerecord-jdbc-adapter/blob/master/activerecord-jdbcmssql-adapter
270
+ [3]: https://github.com/jruby/activerecord-jdbc-adapter/issues
271
+ [4]: http://github.com/nicksieger/activerecord-cachedb-adapter
272
+ [5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
273
+ [6]: https://webchat.freenode.net/?channels=#jruby
274
+ [7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
275
+ [8]: http://rubygems.org/search?query=activerecord-jdbc
276
+ [9]: https://github.com/jruby/activerecord-jdbc-adapter/wiki/Migrating-from-1.3.x-to-1.4.0
277
+ [10]: https://github.com/jruby/activerecord-jdbc-adapter/blob/master/activerecord-jdbc-adapter.gemspec
@@ -0,0 +1,88 @@
1
+
2
+ ## Running AR-JDBC's Tests
3
+
4
+ Most DB specific unit tests hide under the **test/db** directory, the files
5
+ included in the *test* directory are mostly shared test modules and helpers.
6
+
7
+ Rake tasks are loaded from **rakelib/02-test-rake**, most adapters have a
8
+ corresponding test_[adapter] task e.g. `rake test_sqlite3` that run against DB.
9
+ To check all available (test related) tasks simply `rake -T | grep test`.
10
+
11
+ If the adapter supports creating a database it will try to do so automatically
12
+ (most embed databases such as SQLite3) for some adapters (MySQL, PostgreSQL) we
13
+ do this auto-magically (see the `rake db:create` tasks), but otherwise you'll
14
+ need to setup a database dedicated for tests (using the standard tools that come
15
+ with your DB installation).
16
+
17
+ Connection parameters: database, host etc. can usually be changed from the shell
18
+ `env` for adapters where there might be no direct control over the DB
19
+ instance/configuration, e.g. for Oracle (by looking at **test/db/oracle.rb**)
20
+ one might adapt the test database configuration using :
21
+ ```
22
+ export ORACLE_HOST=192.168.1.2
23
+ export ORACLE_USER=SAMPLE
24
+ export ORACLE_PASS=sample
25
+ export ORACLE_SID=MAIN
26
+ ```
27
+
28
+ Tests are by default run against the "current" ActiveRecord version locked down
29
+ by Bundler, however since we usually do support more versions from a single code
30
+ base run those with the (appraisal) provided task e.g. for MySQL :
31
+
32
+ rake appraisal:rails32 test_mysql TEST=test/db/mysql/rake_test.rb
33
+
34
+ Observe the **TEST** variable used to specify a single file to be used to resolve
35
+ test cases, you pick tests by matching their names as well using **TESTOPTS** :
36
+
37
+ rake appraisal:rails40 test_postgres TESTOPTS="--name=/integer/"
38
+
39
+ This of course also works when running the "plain" test (no appraisal:xxx) task.
40
+
41
+ Since 1.3.0 we also support prepared statements, these are off by default (AR)
42
+ but one can easily run tests with prepared statements enabled using env vars :
43
+
44
+ rake test_derby PS=true # or PREPARED_STATEMENTS=true
45
+
46
+ To run tests against specific Rails version, make sure that the all
47
+ required gems are installed. This can be checked by directly running
48
+ the rake task. For eg., for Rails 4.2 :
49
+
50
+ rake appraisal:rails42
51
+
52
+ If the required gems are not present, bundler will give error and will
53
+ ask to do bundle install. This bundle install must be done with the
54
+ Gemfile against which we are running tests. So in this case, bundle
55
+ install can be done using :
56
+
57
+ BUNDLE_GEMFILE=gemfiles/rails42.gemfile bundle install
58
+
59
+ ### ActiveRecord (Rails) Tests
60
+
61
+ It's very desirable to pass all unit tests from ActiveRecord's own test suite.
62
+ Unfortunately it's been a while since we have accomplished that, luckily a lot
63
+ of failures are artificial (and would require tweaks at the Rails repo itself),
64
+ others simply need quality time spent to get them in shape and address issues.
65
+
66
+ First make sure you have the ActiveRecord (Rails) sources cloned locally :
67
+
68
+ git clone git://github.com/rails/rails.git
69
+
70
+ To run the AR-JDBC's sources agains AR tests, use the **rails:test** task, be
71
+ sure to specify a **DRIVER** and the **RAILS** sources path on the file system :
72
+
73
+ jruby -S rake rails:test DRIVER=derby RAILS=path/to/rails_source_dir
74
+
75
+ There's even tasks for Rails built-in adapters e.g. `rake rails:test_mysql`
76
+
77
+ You will likely only be able to run the Rails suite against the latest (stable)
78
+ ActiveRecord ~> version we support (check the *Gemfile.lock*) e.g. for
79
+ **activerecord (3.2.x)** you want to **git checkout 3-2-stable** branch.
80
+
81
+ We strive to not stub and include native (MRI) test required artefacts into
82
+ (non-test) code e.g. the `Mysql` module, instead put that into **test/rails**.
83
+
84
+ [![Build Status][0]](http://travis-ci.org/#!/jruby/activerecord-jdbc-adapter)
85
+
86
+ Happy Testing!
87
+
88
+ [0]: https://secure.travis-ci.org/jruby/activerecord-jdbc-adapter.png
@@ -0,0 +1,298 @@
1
+ require 'rubygems' unless defined? Gem
2
+
3
+ require 'rake/clean'
4
+
5
+ CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
6
+ CLEAN.include 'MANIFEST.MF', '*.log'
7
+
8
+ task :default => :jar # RubyGems extention will do a bare `rake' e.g. :
9
+ # jruby" -rubygems /opt/local/rvm/gems/jruby-1.7.16@jdbc/gems/rake-10.3.2/bin/rake
10
+ # RUBYARCHDIR=/opt/local/rvm/gems/jruby-1.7.16@jdbc/gems/activerecord-jdbc-adapter-1.4.0.dev/lib
11
+ # RUBYLIBDIR=/opt/local/rvm/gems/jruby-1.7.16@jdbc/gems/activerecord-jdbc-adapter-1.4.0.dev/lib
12
+ #
13
+ # under Bundler it points those DIRs to an empty one where only built extensions are stored :
14
+ # jruby -rubygems /opt/local/rvm/gems/jruby-1.7.19@temp/gems/rake-10.4.2/bin/rake
15
+ # RUBYARCHDIR=/opt/local/rvm/gems/jruby-1.7.19@temp/bundler/gems/extensions/universal-java-1.7/1.9/activerecord-jdbc-adapter-472b5fddba43
16
+ # RUBYLIBDIR=/opt/local/rvm/gems/jruby-1.7.19@temp/bundler/gems/extensions/universal-java-1.7/1.9/activerecord-jdbc-adapter-472b5fddba43
17
+ #
18
+ # javac -target 1.6 -source 1.6 -Xlint:unchecked -g -cp
19
+ # "/opt/local/rvm/rubies/jruby-1.7.19/lib/jruby.jar:
20
+ # /opt/local/maven-repo/mysql/mysql-connector-java/5.1.33/mysql-connector-java-5.1.33.jar:
21
+ # /opt/local/maven-repo/org/postgresql/postgresql/9.4-1200-jdbc4/postgresql-9.4-1200-jdbc4.jar"
22
+ # -d /tmp/d20150417-32100-7mb1bk src/java/arjdbc/ArJdbcModule.java ...
23
+
24
+
25
+ base_dir = Dir.pwd
26
+ gem_name = 'activerecord-jdbc-adapter'
27
+ gemspec_path = File.expand_path('activerecord-jdbc-adapter.gemspec', File.dirname(__FILE__))
28
+ gemspec = lambda do
29
+ @_gemspec_ ||= Dir.chdir(File.dirname(__FILE__)) do
30
+ Gem::Specification.load(gemspec_path)
31
+ end
32
+ end
33
+ built_gem_path = lambda do
34
+ Dir[File.join(base_dir, "#{gem_name}-*.gem")].sort_by{ |f| File.mtime(f) }.last
35
+ end
36
+ current_version = lambda { gemspec.call.version }
37
+ rake = lambda { |task| ruby "-S", "rake", task }
38
+
39
+ # NOTE: avoid Bundler loading due native extension building!
40
+
41
+ desc "Build #{gem_name} gem into the pkg directory."
42
+ task :build => :jar do
43
+ sh("gem build -V '#{gemspec_path}'") do
44
+ gem_path = built_gem_path.call
45
+ file_name = File.basename(gem_path)
46
+ FileUtils.mkdir_p(File.join(base_dir, 'pkg'))
47
+ FileUtils.mv(gem_path, 'pkg')
48
+ puts "\n#{gem_name} #{current_version.call} built to 'pkg/#{file_name}'"
49
+ end
50
+ end
51
+
52
+ desc "Build and install #{gem_name} gem into system gems."
53
+ task :install => :build do
54
+ gem_path = built_gem_path.call
55
+ sh("gem install '#{gem_path}' --local") do |ok|
56
+ raise "Couldn't install gem, run `gem install #{gem_path}' for more detailed output" unless ok
57
+ puts "\n#{gem_name} (#{current_version.call}) installed"
58
+ end
59
+ end
60
+
61
+ task 'release:do' => 'build:adapters' do
62
+ ENV['RELEASE'] == 'true' # so that .gemspec is built with adapter_java.jar
63
+ Rake::Task['build'].invoke
64
+
65
+ version = current_version.call; version_tag = "v#{version}"
66
+
67
+ sh("git diff --no-patch --exit-code") { |ok| fail "git working dir is not clean" unless ok }
68
+ sh("git diff-index --quiet --cached HEAD") { |ok| fail "git index is not clean" unless ok }
69
+
70
+ sh "git tag -a -m \"AR-JDBC #{version}\" #{version_tag}"
71
+ branch = `git rev-parse --abbrev-ref HEAD`.strip
72
+ puts "releasing from (current) branch #{branch.inspect}"
73
+ sh "for gem in `ls pkg/*-#{version}.gem`; do gem push $gem; done" do |ok|
74
+ sh "git push origin #{branch} --tags" if ok
75
+ end
76
+ end
77
+
78
+ task 'release:push' do
79
+ sh "for gem in `ls pkg/*-#{current_version.call}.gem`; do gem push $gem; done"
80
+ end
81
+
82
+ ADAPTERS = %w[derby h2 hsqldb mssql mysql postgresql sqlite3].map { |a| "activerecord-jdbc#{a}-adapter" }
83
+ DRIVERS = %w[derby h2 hsqldb jtds mysql postgres sqlite3].map { |a| "jdbc-#{a}" }
84
+ TARGETS = ( ADAPTERS + DRIVERS )
85
+
86
+ ADAPTERS.each do |target|
87
+ namespace target do
88
+ task :build do
89
+ version = current_version.call
90
+ Dir.chdir(target) { rake.call "build" }
91
+ cp FileList["#{target}/pkg/#{target}-#{version}.gem"], "pkg"
92
+ end
93
+ end
94
+ end
95
+ DRIVERS.each do |target|
96
+ namespace target do
97
+ task :build do
98
+ Dir.chdir(target) { rake.call "build" }
99
+ cp FileList["#{target}/pkg/#{target}-*.gem"], "pkg"
100
+ end
101
+ end
102
+ end
103
+ TARGETS.each do |target|
104
+ namespace target do
105
+ task :install do
106
+ Dir.chdir(target) { rake.call "install" }
107
+ end
108
+ task :release do
109
+ Dir.chdir(target) { rake.call "release" }
110
+ end
111
+ end
112
+ end
113
+
114
+ # DRIVERS
115
+
116
+ desc "Build drivers"
117
+ task "build:drivers" => DRIVERS.map { |name| "#{name}:build" }
118
+ task "drivers:build" => 'build:drivers'
119
+
120
+ desc "Install drivers"
121
+ task "install:drivers" => DRIVERS.map { |name| "#{name}:install" }
122
+ task "drivers:install" => 'install:drivers'
123
+
124
+ # ADAPTERS
125
+
126
+ desc "Build adapters"
127
+ task "build:adapters" => [ 'build' ] + ADAPTERS.map { |name| "#{name}:build" }
128
+ task "adapters:build" => 'build:adapters'
129
+
130
+ desc "Install adapters"
131
+ task "install:adapters" => [ 'install' ] + ADAPTERS.map { |name| "#{name}:install" }
132
+ task "adapters:install" => 'install:adapters'
133
+
134
+ # ALL
135
+
136
+ task "build:all" => [ 'build' ] + TARGETS.map { |name| "#{name}:build" }
137
+ task "all:build" => 'build:all'
138
+ task "install:all" => [ 'install' ] + TARGETS.map { |name| "#{name}:install" }
139
+ task "all:install" => 'install:all'
140
+
141
+ require 'rake/testtask'
142
+
143
+ begin
144
+ require 'appraisal'
145
+ rescue LoadError; end
146
+
147
+ # native JRuby extension (adapter_java.jar) compilation :
148
+
149
+ if defined? JRUBY_VERSION
150
+ jar_file = 'lib/arjdbc/jdbc/adapter_java.jar'; CLEAN << jar_file
151
+ desc "Compile the native (Java) extension."
152
+ task :jar => jar_file
153
+
154
+ namespace :jar do
155
+ task :force do
156
+ rm jar_file if File.exist?(jar_file)
157
+ Rake::Task['jar'].invoke
158
+ end
159
+ end
160
+
161
+ #directory classes = 'pkg/classes'; CLEAN << classes
162
+
163
+ file jar_file => FileList[ 'src/java/**/*.java' ] do
164
+ source = target = '1.6'; debug = true
165
+ args = [ '-Xlint:unchecked' ]
166
+
167
+ get_driver_jars_local = lambda do |*args|
168
+ driver_deps = args.empty? ? [ :Postgres, :MySQL ] : args
169
+ driver_jars = []
170
+ driver_deps.each do |name|
171
+ driver_jars << Dir.glob("jdbc-#{name.to_s.downcase}/lib/*.jar").sort.last
172
+ end
173
+ if driver_jars.empty? # likely on a `gem install ...'
174
+ # NOTE: we're currently assuming jdbc-xxx (compile) dependencies are
175
+ # installed, they are declared as gemspec.development_dependencies !
176
+ # ... the other option is to simply `mvn prepare-package'
177
+ driver_deps.each do |name|
178
+ #require "jdbc/#{name.to_s.downcase}"
179
+ #driver_jars << Jdbc.const_get(name).driver_jar
180
+ # thanks Bundler for mocking RubyGems completely :
181
+ #spec = Gem::Specification.find_by_name("jdbc-#{name.to_s.downcase}")
182
+ #driver_jars << Dir.glob(File.join(spec.gem_dir, 'lib/*.jar')).sort.last
183
+ gem_name = "jdbc-#{name.to_s.downcase}"; matched_gem_paths = []
184
+ Gem.paths.path.each do |path|
185
+ base_path = File.join(path, "gems/")
186
+ Dir.glob(File.join(base_path, "*")).each do |gem_path|
187
+ if gem_path.sub(base_path, '').start_with?(gem_name)
188
+ matched_gem_paths << gem_path
189
+ end
190
+ end
191
+ end
192
+ if gem_path = matched_gem_paths.sort.last
193
+ driver_jars << Dir.glob(File.join(gem_path, 'lib/*.jar')).sort.last
194
+ end
195
+ end
196
+ end
197
+ driver_jars
198
+ end
199
+
200
+ get_driver_jars_maven = lambda do
201
+ require 'jar_dependencies'
202
+
203
+ requirements = gemspec.call.requirements
204
+ match_driver_jars = lambda do
205
+ matched_jars = []
206
+ gemspec.call.requirements.each do |requirement|
207
+ if match = requirement.match(/^jar\s+([\w\-\.]+):([\w\-]+),\s+?([\w\.\-]+)?/)
208
+ matched_jar = Jars.send :to_jar, match[1], match[2], match[3], nil
209
+ matched_jar = File.join( Jars.home, matched_jar )
210
+ matched_jars << matched_jar if File.exists?( matched_jar )
211
+ end
212
+ end
213
+ matched_jars
214
+ end
215
+
216
+ driver_jars = match_driver_jars.call
217
+ if driver_jars.size < requirements.size
218
+ if (ENV['JARS_SKIP'] || ENV_JAVA['jars.skip']) == 'true'
219
+ warn "jar resolving skipped, extension might not compile"
220
+ else
221
+ require 'jars/installer'
222
+ ENV['JARS_QUIET'] = 'true'
223
+ puts "resolving jar dependencies to build extension (should only happen once) ..."
224
+ installer = Jars::Installer.new( gemspec_path )
225
+ installer.install_jars( false )
226
+
227
+ driver_jars = match_driver_jars.call
228
+ end
229
+ end
230
+
231
+ driver_jars
232
+ end
233
+
234
+ if ENV['RUBYARCHDIR'] || ENV['BUILD_EXT_MAVEN'] == 'true'
235
+ driver_jars = get_driver_jars_maven.call
236
+ else
237
+ driver_jars = get_driver_jars_local.call
238
+ end
239
+
240
+ classpath = []
241
+ [ 'java.class.path', 'sun.boot.class.path' ].each do |key|
242
+ classpath += ENV_JAVA[key].split(File::PATH_SEPARATOR).find_all { |jar| jar =~ /jruby/i }
243
+ end
244
+ #classpath += ENV_JAVA['java.class.path'].split(File::PATH_SEPARATOR)
245
+ #classpath += ENV_JAVA['sun.boot.class.path'].split(File::PATH_SEPARATOR)
246
+
247
+ classpath += driver_jars
248
+ classpath = classpath.compact.join(File::PATH_SEPARATOR)
249
+
250
+ source_files = FileList[ 'src/java/**/*.java' ]
251
+
252
+ require 'tmpdir'
253
+
254
+ Dir.mktmpdir do |classes_dir|
255
+ # Cross-platform way of finding an executable in the $PATH.
256
+ # Thanks to @mislav
257
+ which = lambda do |cmd|
258
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
259
+ ENV['PATH'].split(File::PATH_SEPARATOR).map do |path|
260
+ exts.map { |ext| File.join(path, "#{cmd}#{ext}") }
261
+ end.flatten.select{|f| File.executable? f}.first
262
+ end
263
+
264
+ unless javac = which.call('javac')
265
+ warn "could not find javac, please make sure it's on the PATH"
266
+ end
267
+ javac = "#{javac} -target #{target} -source #{source} #{args.join(' ')}"
268
+ javac << " #{debug ? '-g' : ''}"
269
+ javac << " -cp \"#{classpath}\" -d #{classes_dir} #{source_files.join(' ')}"
270
+ sh(javac) do |ok|
271
+ raise 'could not build .jar extension - compilation failure' unless ok
272
+ end
273
+
274
+ # class_files = FileList["#{classes_dir}/**/*.class"].gsub("#{classes_dir}/", '')
275
+ # avoid environment variable expansion using backslash
276
+ # class_files.gsub!('$', '\$') unless windows?
277
+ # args = class_files.map { |path| [ "-C #{classes_dir}", path ] }.flatten
278
+ args = [ '-C', "#{classes_dir}/ ." ] # args = class_files
279
+
280
+ jar_path = jar_file
281
+ if ext_lib_dir = ENV['RUBYLIBDIR']
282
+ jar_path = File.join(ext_lib_dir, File.basename(jar_file))
283
+ end
284
+
285
+ unless jar = which.call('jar')
286
+ warn "could not find jar tool, please make sure it's on the PATH"
287
+ end
288
+ sh("#{jar} cf #{jar_path} #{args.join(' ')}") do |ok|
289
+ raise 'could not build .jar extension - packaging failure' unless ok
290
+ end
291
+ cp jar_path, jar_file if ext_lib_dir # NOTE: hopefully RG won't mind?!
292
+ end
293
+ end
294
+ else
295
+ task :jar do
296
+ puts "please run `rake jar' under JRuby to re-compile the native (Java) extension"
297
+ end
298
+ end