activerecord-jdbc-adapter 72.1-java → 80.0.pre1-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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +129 -24
  3. data/.mise.toml +3 -0
  4. data/Gemfile +42 -47
  5. data/README.md +3 -2
  6. data/Rakefile +62 -14
  7. data/activerecord-jdbc-adapter.gemspec +2 -2
  8. data/lib/arjdbc/abstract/core.rb +1 -1
  9. data/lib/arjdbc/abstract/database_statements.rb +11 -7
  10. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  11. data/lib/arjdbc/mysql/adapter_hash_config.rb +1 -2
  12. data/lib/arjdbc/postgresql/adapter.rb +4 -1
  13. data/lib/arjdbc/sqlite3/adapter.rb +48 -7
  14. data/lib/arjdbc/version.rb +1 -1
  15. data/pom.xml +3 -3
  16. data/rakelib/db.rake +5 -3
  17. data/rakelib/rails.rake +0 -1
  18. data/src/java/arjdbc/ArJdbcModule.java +13 -10
  19. data/src/java/arjdbc/db2/DB2Module.java +4 -4
  20. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +8 -9
  21. data/src/java/arjdbc/h2/H2Module.java +2 -1
  22. data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +8 -7
  23. data/src/java/arjdbc/hsqldb/HSQLDBModule.java +5 -6
  24. data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +4 -3
  25. data/src/java/arjdbc/jdbc/DriverWrapper.java +13 -8
  26. data/src/java/arjdbc/jdbc/JdbcResult.java +10 -7
  27. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +168 -154
  28. data/src/java/arjdbc/mssql/MSSQLModule.java +3 -3
  29. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +13 -9
  30. data/src/java/arjdbc/mysql/MySQLModule.java +3 -3
  31. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +30 -24
  32. data/src/java/arjdbc/oracle/OracleModule.java +2 -3
  33. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +22 -18
  34. data/src/java/arjdbc/postgresql/PostgreSQLModule.java +2 -3
  35. data/src/java/arjdbc/postgresql/PostgreSQLResult.java +24 -12
  36. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +16 -12
  37. data/src/java/arjdbc/sqlite3/SQLite3Module.java +2 -3
  38. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +78 -29
  39. data/src/java/arjdbc/util/DateTimeUtils.java +7 -5
  40. data/src/java/arjdbc/util/ObjectSupport.java +2 -2
  41. data/src/java/arjdbc/util/StringHelper.java +1 -1
  42. metadata +6 -6
  43. data/.travis.yml +0 -128
@@ -31,6 +31,7 @@ import java.io.InputStreamReader;
31
31
  import java.io.PrintStream;
32
32
  import java.io.Reader;
33
33
  import java.io.StringReader;
34
+ import java.lang.reflect.InvocationTargetException;
34
35
  import java.math.BigDecimal;
35
36
  import java.math.BigInteger;
36
37
  import java.sql.Array;
@@ -109,6 +110,14 @@ import arjdbc.util.StringCache;
109
110
  import static arjdbc.jdbc.DataSourceConnectionFactory.*;
110
111
  import static arjdbc.util.StringHelper.*;
111
112
  import static org.jruby.RubyTime.getLocalTimeZone;
113
+ import static org.jruby.api.Access.getModule;
114
+ import static org.jruby.api.Access.objectClass;
115
+ import static org.jruby.api.Convert.asFixnum;
116
+ import static org.jruby.api.Convert.toInt;
117
+ import static org.jruby.api.Create.allocArray;
118
+ import static org.jruby.api.Create.newArray;
119
+ import static org.jruby.api.Create.newArrayNoCopy;
120
+ import static org.jruby.api.Create.newEmptyArray;
112
121
 
113
122
 
114
123
  /**
@@ -135,8 +144,9 @@ public class RubyJdbcConnection extends RubyObject {
135
144
 
136
145
  protected RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
137
146
  super(runtime, metaClass);
138
- attributeClass = runtime.getModule("ActiveModel").getClass("Attribute");
139
- timeZoneClass = runtime.getModule("ActiveSupport").getClass("TimeWithZone");
147
+ var context = runtime.getCurrentContext();
148
+ attributeClass = getModule(context, "ActiveModel").getClass(context, "Attribute");
149
+ timeZoneClass = getModule(context, "ActiveSupport").getClass(context, "TimeWithZone");
140
150
  }
141
151
 
142
152
  private static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
@@ -146,87 +156,92 @@ public class RubyJdbcConnection extends RubyObject {
146
156
  };
147
157
 
148
158
  public static RubyClass createJdbcConnectionClass(final Ruby runtime) {
149
- final RubyClass JdbcConnection = getConnectionAdapters(runtime).
150
- defineClassUnder("JdbcConnection", runtime.getObject(), ALLOCATOR);
151
- JdbcConnection.defineAnnotatedMethods(RubyJdbcConnection.class);
152
- return JdbcConnection;
159
+ var context = runtime.getCurrentContext();
160
+ return getConnectionAdapters(context).
161
+ defineClassUnder(context, "JdbcConnection", runtime.getObject(), ALLOCATOR).
162
+ defineMethods(context, RubyJdbcConnection.class);
153
163
  }
154
164
 
155
- public static RubyClass getJdbcConnection(final Ruby runtime) {
156
- return (RubyClass) getConnectionAdapters(runtime).getConstantAt("JdbcConnection");
165
+ public static RubyClass getJdbcConnection(ThreadContext context) {
166
+ return getConnectionAdapters(context).getClass(context, "JdbcConnection");
157
167
  }
158
168
 
159
169
  protected static RubyModule ActiveRecord(ThreadContext context) {
160
- return context.runtime.getModule("ActiveRecord");
170
+ return getModule(context, "ActiveRecord");
161
171
  }
162
172
 
163
- public static RubyClass getBase(final Ruby runtime) {
164
- return (RubyClass) runtime.getModule("ActiveRecord").getConstantAt("Base");
173
+ @Deprecated
174
+ public static RubyClass getBase(ThreadContext context) {
175
+ return getModule(context, "ActiveRecord").getClass("Base");
165
176
  }
166
177
 
167
178
  /**
168
- * @param runtime
179
+ * @param context the thread context
169
180
  * @return <code>ActiveRecord::Result</code>
170
181
  */
171
- public static RubyClass getResult(final Ruby runtime) {
172
- return (RubyClass) runtime.getModule("ActiveRecord").getConstantAt("Result");
182
+ public static RubyClass getResult(ThreadContext context) {
183
+ return getModule(context, "ActiveRecord").getClass(context, "Result");
173
184
  }
174
185
 
175
186
  /**
176
- * @param runtime
187
+ * @param context the thread context
177
188
  * @return <code>ActiveRecord::ConnectionAdapters</code>
178
189
  */
179
- public static RubyModule getConnectionAdapters(final Ruby runtime) {
180
- return (RubyModule) runtime.getModule("ActiveRecord").getConstantAt("ConnectionAdapters");
190
+ public static RubyModule getConnectionAdapters(ThreadContext context) {
191
+ return getModule(context, "ActiveRecord").getModule(context, "ConnectionAdapters");
181
192
  }
182
193
 
183
194
  /**
184
- * @param runtime
195
+ * resolve <code>ActiveRecord::ConnectionAdapters::IndexDefinition</code>.
196
+ *
197
+ * @param context the thread context
185
198
  * @return <code>ActiveRecord::ConnectionAdapters::IndexDefinition</code>
186
199
  */
187
- protected static RubyClass getIndexDefinition(final Ruby runtime) {
188
- return getConnectionAdapters(runtime).getClass("IndexDefinition");
200
+ protected static RubyClass indexDefinition(ThreadContext context) {
201
+ return getConnectionAdapters(context).getClass(context, "IndexDefinition");
189
202
  }
190
203
 
191
204
  /**
192
- * @param runtime
205
+ * resolve <code>ActiveRecord::ConnectionAdapters::ForeignKeyDefinition</code>.
206
+ *
207
+ * @param context the thread context.
193
208
  * @return <code>ActiveRecord::ConnectionAdapters::ForeignKeyDefinition</code>
194
209
  * @note only since AR 4.2
195
210
  */
196
- protected static RubyClass getForeignKeyDefinition(final Ruby runtime) {
197
- return getConnectionAdapters(runtime).getClass("ForeignKeyDefinition");
211
+ protected static RubyClass foreignKeyDefinition(ThreadContext context) {
212
+ return getConnectionAdapters(context).getClass(context, "ForeignKeyDefinition");
198
213
  }
199
214
 
200
215
  /**
201
- * @param runtime
216
+ * @param context the thread context
202
217
  * @return <code>ActiveRecord::JDBCError</code>
203
218
  */
204
- protected static RubyClass getJDBCError(final Ruby runtime) {
205
- return runtime.getModule("ActiveRecord").getClass("JDBCError");
219
+ protected static RubyClass getJDBCError(ThreadContext context) {
220
+ return getModule(context, "ActiveRecord").getClass(context, "JDBCError");
206
221
  }
207
222
 
208
223
  /**
209
- * @param runtime
224
+ * @param context the thread context
210
225
  * @return <code>ActiveRecord::ConnectionNotEstablished</code>
211
226
  */
212
- protected static RubyClass getConnectionNotEstablished(final Ruby runtime) {
213
- return runtime.getModule("ActiveRecord").getClass("ConnectionNotEstablished");
227
+ protected static RubyClass getConnectionNotEstablished(ThreadContext context) {
228
+ return getModule(context, "ActiveRecord").getClass(context, "ConnectionNotEstablished");
214
229
  }
215
230
 
216
231
  /**
217
- * @param runtime
232
+ * @param context the thread context
218
233
  * @return <code>ActiveRecord::NoDatabaseError</code>
219
234
  */
220
- protected static RubyClass getNoDatabaseError(final Ruby runtime) {
221
- return runtime.getModule("ActiveRecord").getClass("NoDatabaseError");
235
+ protected static RubyClass getNoDatabaseError(ThreadContext context) {
236
+ return getModule(context, "ActiveRecord").getClass(context, "NoDatabaseError");
222
237
  }
223
238
 
224
239
  /**
225
- * @param runtime
240
+ * @param context the thread context
226
241
  * @return <code>ActiveRecord::TransactionIsolationError</code>
227
242
  */
228
- protected static RubyClass getTransactionIsolationError(final Ruby runtime) {
229
- return (RubyClass) runtime.getModule("ActiveRecord").getConstant("TransactionIsolationError");
243
+ protected static RubyClass getTransactionIsolationError(ThreadContext context) {
244
+ return getModule(context, "ActiveRecord").getClass(context, "TransactionIsolationError");
230
245
  }
231
246
 
232
247
  @JRubyMethod(name = "transaction_isolation", alias = "get_transaction_isolation")
@@ -351,7 +366,7 @@ public class RubyJdbcConnection extends RubyObject {
351
366
  connection.setTransactionIsolation(level);
352
367
  }
353
368
  catch (SQLException e) {
354
- RubyClass txError = ActiveRecord(context).getClass("TransactionIsolationError");
369
+ RubyClass txError = ActiveRecord(context).getClass(context, "TransactionIsolationError");
355
370
  if ( txError != null ) throw wrapException(context, txError, e);
356
371
  throw e; // let it roll - will be wrapped into a JDBCError (non 4.0)
357
372
  }
@@ -485,7 +500,7 @@ public class RubyJdbcConnection extends RubyObject {
485
500
  }
486
501
 
487
502
  protected static RuntimeException newSavepointNotSetError(final ThreadContext context, final IRubyObject name, final String op) {
488
- RubyClass StatementInvalid = ActiveRecord(context).getClass("StatementInvalid");
503
+ RubyClass StatementInvalid = ActiveRecord(context).getClass(context, "StatementInvalid");
489
504
  return context.runtime.newRaiseException(StatementInvalid, "could not " + op + " savepoint: '" + name + "' (not set)");
490
505
  }
491
506
 
@@ -495,13 +510,13 @@ public class RubyJdbcConnection extends RubyObject {
495
510
  @SuppressWarnings("unchecked")
496
511
  final Map<IRubyObject, Savepoint> savepoints = getSavepoints(false);
497
512
  if ( savepoints != null ) {
498
- final RubyArray names = context.runtime.newArray(savepoints.size());
513
+ final RubyArray names = allocArray(context, savepoints.size());
499
514
  for ( Map.Entry<IRubyObject, ?> entry : savepoints.entrySet() ) {
500
- names.append( entry.getKey() ); // keys are RubyString instances
515
+ names.append(context, entry.getKey()); // keys are RubyString instances
501
516
  }
502
517
  return names;
503
518
  }
504
- return context.runtime.newEmptyArray();
519
+ return newEmptyArray(context);
505
520
  }
506
521
 
507
522
  protected Map<IRubyObject, Savepoint> getSavepoints(final ThreadContext context) {
@@ -562,7 +577,7 @@ public class RubyJdbcConnection extends RubyObject {
562
577
 
563
578
  IRubyObject jdbcFetchSize = getConfigValue(context, "jdbc_fetch_size");
564
579
  if (jdbcFetchSize != context.nil) {
565
- this.fetchSize = RubyNumeric.fix2int(jdbcFetchSize);
580
+ this.fetchSize = toInt(context, jdbcFetchSize);
566
581
  }
567
582
  }
568
583
 
@@ -1021,7 +1036,7 @@ public class RubyJdbcConnection extends RubyObject {
1021
1036
  switch (args.length) {
1022
1037
  case 2:
1023
1038
  if (args[1] instanceof RubyNumeric) { // (sql, max_rows)
1024
- maxRows = RubyNumeric.fix2int(args[1]);
1039
+ maxRows = toInt(context, args[1]);
1025
1040
  binds = null;
1026
1041
  } else { // (sql, binds)
1027
1042
  maxRows = 0;
@@ -1029,7 +1044,7 @@ public class RubyJdbcConnection extends RubyObject {
1029
1044
  }
1030
1045
  break;
1031
1046
  case 3: // (sql, max_rows, binds)
1032
- maxRows = RubyNumeric.fix2int(args[1]);
1047
+ maxRows = toInt(context, args[1]);
1033
1048
  binds = (RubyArray) TypeConverter.checkArrayType(context, args[2]);
1034
1049
  break;
1035
1050
  default: // (sql) 1-arg
@@ -1071,7 +1086,7 @@ public class RubyJdbcConnection extends RubyObject {
1071
1086
  if (hasResult) {
1072
1087
  return mapToRawResult(context, connection, statement.getResultSet(), false);
1073
1088
  }
1074
- return context.runtime.newEmptyArray();
1089
+ return newEmptyArray(context);
1075
1090
  }
1076
1091
  catch (final SQLException e) {
1077
1092
  debugErrorSQL(context, query);
@@ -1238,7 +1253,7 @@ public class RubyJdbcConnection extends RubyObject {
1238
1253
  public IRubyObject primary_keys(ThreadContext context, IRubyObject tableName) throws SQLException {
1239
1254
  @SuppressWarnings("unchecked")
1240
1255
  List<IRubyObject> primaryKeys = (List) primaryKeys(context, tableName.toString());
1241
- return context.runtime.newArray(primaryKeys);
1256
+ return newArray(context, primaryKeys);
1242
1257
  }
1243
1258
 
1244
1259
  protected static final int PRIMARY_KEYS_COLUMN_NAME = 4;
@@ -1386,7 +1401,7 @@ public class RubyJdbcConnection extends RubyObject {
1386
1401
  final List<RubyString> primaryKeys = primaryKeys(context, connection, table);
1387
1402
 
1388
1403
  ResultSet indexInfoSet = null;
1389
- final RubyArray indexes = RubyArray.newArray(runtime, 8);
1404
+ final RubyArray indexes = allocArray(context, 8);
1390
1405
  try {
1391
1406
  final DatabaseMetaData metaData = connection.getMetaData();
1392
1407
  indexInfoSet = metaData.getIndexInfo(table.catalog, table.schema, table.name, false, true);
@@ -1418,15 +1433,15 @@ public class RubyJdbcConnection extends RubyObject {
1418
1433
  cachedString(context, indexTableName), // table_name
1419
1434
  cachedString(context, indexName), // index_name
1420
1435
  nonUnique ? context.fals : context.tru, // unique
1421
- currentColumns = RubyArray.newArray(runtime, 4) // [] column names
1436
+ currentColumns = allocArray(context, 4) // [] column names
1422
1437
  // orders, (since AR 3.2) where, type, using (AR 4.0)
1423
1438
  };
1424
1439
 
1425
- indexes.append( IndexDefinition.newInstance(context, args, Block.NULL_BLOCK) ); // IndexDefinition.new
1440
+ indexes.append(context, IndexDefinition.newInstance(context, args, Block.NULL_BLOCK)); // IndexDefinition.new
1426
1441
  }
1427
1442
 
1428
1443
  // one or more columns can be associated with an index
1429
- if ( currentColumns != null ) currentColumns.append(rubyColumnName);
1444
+ if ( currentColumns != null ) currentColumns.append(context, rubyColumnName);
1430
1445
  }
1431
1446
 
1432
1447
  return indexes;
@@ -1436,9 +1451,8 @@ public class RubyJdbcConnection extends RubyObject {
1436
1451
  }
1437
1452
 
1438
1453
  protected RubyClass getIndexDefinition(final ThreadContext context) {
1439
- final RubyClass adapterClass = adapter.getMetaClass();
1440
- IRubyObject IDef = adapterClass.getConstantAt("IndexDefinition");
1441
- return IDef != null ? (RubyClass) IDef : getIndexDefinition(context.runtime);
1454
+ var IDef = adapter.getMetaClass().getClass(context, "IndexDefinition");
1455
+ return IDef != null ? IDef : indexDefinition(context);
1442
1456
  }
1443
1457
 
1444
1458
  @JRubyMethod
@@ -1493,7 +1507,7 @@ public class RubyJdbcConnection extends RubyObject {
1493
1507
  fKeys.add( FKDefinition.newInstance(context, from_table, to_table, options, Block.NULL_BLOCK) ); // ForeignKeyDefinition.new
1494
1508
  }
1495
1509
 
1496
- return runtime.newArray(fKeys);
1510
+ return newArray(context, fKeys);
1497
1511
 
1498
1512
  } finally { close(fkInfoSet); }
1499
1513
  });
@@ -1511,8 +1525,8 @@ public class RubyJdbcConnection extends RubyObject {
1511
1525
 
1512
1526
  protected RubyClass getForeignKeyDefinition(final ThreadContext context) {
1513
1527
  final RubyClass adapterClass = adapter.getMetaClass();
1514
- IRubyObject FKDef = adapterClass.getConstantAt("ForeignKeyDefinition");
1515
- return FKDef != null ? (RubyClass) FKDef : getForeignKeyDefinition(context.runtime);
1528
+ var FKDef = adapterClass.getClass(context, "ForeignKeyDefinition");
1529
+ return FKDef != null ? FKDef : foreignKeyDefinition(context);
1516
1530
  }
1517
1531
 
1518
1532
 
@@ -1619,7 +1633,7 @@ public class RubyJdbcConnection extends RubyObject {
1619
1633
  }
1620
1634
  setStatementParameter(context, context.runtime, connection, statement, 2, idValue, idColumn);
1621
1635
  */
1622
- return statement.executeUpdate();
1636
+ return (Integer) statement.executeUpdate();
1623
1637
  }
1624
1638
  finally { close(statement); }
1625
1639
  });
@@ -1700,7 +1714,7 @@ public class RubyJdbcConnection extends RubyObject {
1700
1714
  return block.call(context, JavaUtil.convertJavaToRuby(context.runtime, metaData));
1701
1715
  }
1702
1716
  catch (SQLException e) {
1703
- throw wrapSQLException(context, getJDBCError(context.runtime), e, null);
1717
+ throw wrapSQLException(context, getJDBCError(context), e, null);
1704
1718
  }
1705
1719
  finally { close(connection); }
1706
1720
  }
@@ -1766,9 +1780,8 @@ public class RubyJdbcConnection extends RubyObject {
1766
1780
  final IRubyObject driver_instance = getConfigValue(context, "driver_instance");
1767
1781
 
1768
1782
  if ( url.isNil() || ( driver.isNil() && driver_instance.isNil() ) ) {
1769
- final Ruby runtime = context.runtime;
1770
- final RubyClass errorClass = getConnectionNotEstablished( runtime );
1771
- throw runtime.newRaiseException(errorClass, "adapter requires :driver class and jdbc :url");
1783
+ final RubyClass errorClass = getConnectionNotEstablished(context);
1784
+ throw context.runtime.newRaiseException(errorClass, "adapter requires :driver class and jdbc :url");
1772
1785
  }
1773
1786
 
1774
1787
  final String jdbcURL = buildURL(context, url);
@@ -1824,6 +1837,10 @@ public class RubyJdbcConnection extends RubyObject {
1824
1837
  }
1825
1838
  catch (SecurityException e) {
1826
1839
  throw wrapException(context, context.runtime.getSecurityError(), e);
1840
+ } catch (InvocationTargetException e) {
1841
+ throw wrapException(context, context.runtime.getNameError(), e, "invalid invocation target for " + driver);
1842
+ } catch (NoSuchMethodException e) {
1843
+ throw wrapException(context, context.runtime.getNameError(), e, "cannot find constructor for " + driver);
1827
1844
  }
1828
1845
  }
1829
1846
 
@@ -2008,10 +2025,10 @@ public class RubyJdbcConnection extends RubyObject {
2008
2025
  final ResultSet resultSet, final ColumnData[] columns) throws SQLException {
2009
2026
  final Ruby runtime = context.runtime;
2010
2027
 
2011
- final RubyArray resultRows = runtime.newArray();
2028
+ final RubyArray resultRows = newArray(context);
2012
2029
 
2013
2030
  while (resultSet.next()) {
2014
- resultRows.append(mapRow(context, runtime, columns, resultSet, this));
2031
+ resultRows.append(context, mapRow(context, runtime, columns, resultSet, this));
2015
2032
  }
2016
2033
 
2017
2034
  return newResult(context, columns, resultRows);
@@ -2163,7 +2180,7 @@ public class RubyJdbcConnection extends RubyObject {
2163
2180
  static {
2164
2181
  final String dateTimeRaw = SafePropertyAccessor.getProperty("arjdbc.datetime.raw");
2165
2182
  if ( dateTimeRaw != null ) {
2166
- rawDateTime = Boolean.parseBoolean(dateTimeRaw);
2183
+ rawDateTime = (Boolean) Boolean.parseBoolean(dateTimeRaw);
2167
2184
  }
2168
2185
  // NOTE: we do this since it will have a different value depending on
2169
2186
  // AR version - since 4.0 false by default otherwise will be true ...
@@ -2178,7 +2195,7 @@ public class RubyJdbcConnection extends RubyObject {
2178
2195
  @JRubyMethod(name = "raw_date_time=", meta = true)
2179
2196
  public static IRubyObject setRawDateTime(final IRubyObject self, final IRubyObject value) {
2180
2197
  if ( value instanceof RubyBoolean ) {
2181
- rawDateTime = ((RubyBoolean) value).isTrue();
2198
+ rawDateTime = (Boolean) value.isTrue();
2182
2199
  }
2183
2200
  else {
2184
2201
  rawDateTime = value.isNil() ? null : Boolean.TRUE;
@@ -2244,7 +2261,7 @@ public class RubyJdbcConnection extends RubyObject {
2244
2261
  static {
2245
2262
  final String booleanRaw = SafePropertyAccessor.getProperty("arjdbc.boolean.raw");
2246
2263
  if ( booleanRaw != null ) {
2247
- rawBoolean = Boolean.parseBoolean(booleanRaw);
2264
+ rawBoolean = (Boolean) Boolean.parseBoolean(booleanRaw);
2248
2265
  }
2249
2266
  }
2250
2267
 
@@ -2257,7 +2274,7 @@ public class RubyJdbcConnection extends RubyObject {
2257
2274
  @JRubyMethod(name = "raw_boolean=", meta = true)
2258
2275
  public static IRubyObject setRawBoolean(final IRubyObject self, final IRubyObject value) {
2259
2276
  if ( value instanceof RubyBoolean ) {
2260
- rawBoolean = ((RubyBoolean) value).isTrue();
2277
+ rawBoolean = (Boolean) value.isTrue();
2261
2278
  }
2262
2279
  else {
2263
2280
  rawBoolean = value.isNil() ? null : Boolean.TRUE;
@@ -2372,7 +2389,7 @@ public class RubyJdbcConnection extends RubyObject {
2372
2389
  try {
2373
2390
  if ( value == null ) return context.nil;
2374
2391
 
2375
- final RubyArray array = runtime.newArray();
2392
+ final RubyArray array = newArray(context);
2376
2393
 
2377
2394
  final ResultSet arrayResult = value.getResultSet(); // 1: index, 2: value
2378
2395
  final int baseType = value.getBaseType();
@@ -2393,7 +2410,7 @@ public class RubyJdbcConnection extends RubyObject {
2393
2410
  }
2394
2411
 
2395
2412
  while ( arrayResult.next() ) {
2396
- array.append( jdbcToRuby(context, runtime, 2, baseType, arrayResult) );
2413
+ array.append(context, jdbcToRuby(context, runtime, 2, baseType, arrayResult));
2397
2414
  }
2398
2415
  arrayResult.close();
2399
2416
 
@@ -2519,38 +2536,38 @@ public class RubyJdbcConnection extends RubyObject {
2519
2536
 
2520
2537
  protected static final Map<String, Integer> JDBC_TYPE_FOR = new HashMap<>(32, 1);
2521
2538
  static {
2522
- JDBC_TYPE_FOR.put("string", Types.VARCHAR);
2523
- JDBC_TYPE_FOR.put("text", Types.CLOB);
2524
- JDBC_TYPE_FOR.put("integer", Types.INTEGER);
2525
- JDBC_TYPE_FOR.put("float", Types.FLOAT);
2526
- JDBC_TYPE_FOR.put("real", Types.REAL);
2527
- JDBC_TYPE_FOR.put("decimal", Types.DECIMAL);
2528
- JDBC_TYPE_FOR.put("date", Types.DATE);
2529
- JDBC_TYPE_FOR.put("time", Types.TIME);
2530
- JDBC_TYPE_FOR.put("datetime", Types.TIMESTAMP);
2531
- JDBC_TYPE_FOR.put("timestamp", Types.TIMESTAMP);
2532
- JDBC_TYPE_FOR.put("boolean", Types.BOOLEAN);
2533
- JDBC_TYPE_FOR.put("array", Types.ARRAY);
2534
- JDBC_TYPE_FOR.put("xml", Types.SQLXML);
2539
+ JDBC_TYPE_FOR.put("string", Integer.valueOf(Types.VARCHAR));
2540
+ JDBC_TYPE_FOR.put("text", Integer.valueOf(Types.CLOB));
2541
+ JDBC_TYPE_FOR.put("integer", Integer.valueOf(Types.INTEGER));
2542
+ JDBC_TYPE_FOR.put("float", Integer.valueOf(Types.FLOAT));
2543
+ JDBC_TYPE_FOR.put("real", Integer.valueOf(Types.REAL));
2544
+ JDBC_TYPE_FOR.put("decimal", Integer.valueOf(Types.DECIMAL));
2545
+ JDBC_TYPE_FOR.put("date", Integer.valueOf(Types.DATE));
2546
+ JDBC_TYPE_FOR.put("time", Integer.valueOf(Types.TIME));
2547
+ JDBC_TYPE_FOR.put("datetime", Integer.valueOf(Types.TIMESTAMP));
2548
+ JDBC_TYPE_FOR.put("timestamp", Integer.valueOf(Types.TIMESTAMP));
2549
+ JDBC_TYPE_FOR.put("boolean", Integer.valueOf(Types.BOOLEAN));
2550
+ JDBC_TYPE_FOR.put("array", Integer.valueOf(Types.ARRAY));
2551
+ JDBC_TYPE_FOR.put("xml", Integer.valueOf(Types.SQLXML));
2535
2552
 
2536
2553
  // also mapping standard SQL names :
2537
- JDBC_TYPE_FOR.put("bit", Types.BIT);
2538
- JDBC_TYPE_FOR.put("tinyint", Types.TINYINT);
2539
- JDBC_TYPE_FOR.put("smallint", Types.SMALLINT);
2540
- JDBC_TYPE_FOR.put("bigint", Types.BIGINT);
2541
- JDBC_TYPE_FOR.put("int", Types.INTEGER);
2542
- JDBC_TYPE_FOR.put("double", Types.DOUBLE);
2543
- JDBC_TYPE_FOR.put("numeric", Types.NUMERIC);
2544
- JDBC_TYPE_FOR.put("char", Types.CHAR);
2545
- JDBC_TYPE_FOR.put("varchar", Types.VARCHAR);
2546
- JDBC_TYPE_FOR.put("binary", Types.BINARY);
2547
- JDBC_TYPE_FOR.put("varbinary", Types.VARBINARY);
2554
+ JDBC_TYPE_FOR.put("bit", Integer.valueOf(Types.BIT));
2555
+ JDBC_TYPE_FOR.put("tinyint", Integer.valueOf(Types.TINYINT));
2556
+ JDBC_TYPE_FOR.put("smallint", Integer.valueOf(Types.SMALLINT));
2557
+ JDBC_TYPE_FOR.put("bigint", Integer.valueOf(Types.BIGINT));
2558
+ JDBC_TYPE_FOR.put("int", Integer.valueOf(Types.INTEGER));
2559
+ JDBC_TYPE_FOR.put("double", Integer.valueOf(Types.DOUBLE));
2560
+ JDBC_TYPE_FOR.put("numeric", Integer.valueOf(Types.NUMERIC));
2561
+ JDBC_TYPE_FOR.put("char", Integer.valueOf(Types.CHAR));
2562
+ JDBC_TYPE_FOR.put("varchar", Integer.valueOf(Types.VARCHAR));
2563
+ JDBC_TYPE_FOR.put("binary", Integer.valueOf(Types.BINARY));
2564
+ JDBC_TYPE_FOR.put("varbinary", Integer.valueOf(Types.VARBINARY));
2548
2565
  //JDBC_TYPE_FOR.put("struct", Types.STRUCT);
2549
- JDBC_TYPE_FOR.put("blob", Types.BLOB);
2550
- JDBC_TYPE_FOR.put("clob", Types.CLOB);
2551
- JDBC_TYPE_FOR.put("nchar", Types.NCHAR);
2552
- JDBC_TYPE_FOR.put("nvarchar", Types.NVARCHAR);
2553
- JDBC_TYPE_FOR.put("nclob", Types.NCLOB);
2566
+ JDBC_TYPE_FOR.put("blob", Integer.valueOf(Types.BLOB));
2567
+ JDBC_TYPE_FOR.put("clob", Integer.valueOf(Types.CLOB));
2568
+ JDBC_TYPE_FOR.put("nchar", Integer.valueOf(Types.NCHAR));
2569
+ JDBC_TYPE_FOR.put("nvarchar", Integer.valueOf(Types.NVARCHAR));
2570
+ JDBC_TYPE_FOR.put("nclob", Integer.valueOf(Types.NCLOB));
2554
2571
  }
2555
2572
 
2556
2573
  protected int jdbcTypeForAttribute(final ThreadContext context,
@@ -2650,7 +2667,7 @@ public class RubyJdbcConnection extends RubyObject {
2650
2667
  }
2651
2668
 
2652
2669
  protected DateTimeZone getDefaultTimeZone(final ThreadContext context) {
2653
- return isDefaultTimeZoneUTC(context) ? DateTimeZone.UTC : getLocalTimeZone(context.runtime); // handles ENV['TZ']
2670
+ return isDefaultTimeZoneUTC(context) ? DateTimeZone.UTC : getLocalTimeZone(context); // handles ENV['TZ']
2654
2671
  }
2655
2672
 
2656
2673
  private String default_timezone(final ThreadContext context) {
@@ -2667,13 +2684,13 @@ public class RubyJdbcConnection extends RubyObject {
2667
2684
  final IRubyObject attribute, final int type) throws SQLException {
2668
2685
 
2669
2686
  if ( value instanceof RubyBignum ) { // e.g. HSQLDB / H2 report JDBC type 4
2670
- setBigIntegerParameter(context, connection, statement, index, (RubyBignum) value, attribute, type);
2687
+ setBigIntegerParameter(context, connection, statement, index, value, attribute, type);
2671
2688
  }
2672
2689
  else if ( value instanceof RubyNumeric ) {
2673
2690
  statement.setLong(index, RubyNumeric.num2long(value));
2674
2691
  }
2675
2692
  else {
2676
- statement.setLong(index, value.convertToInteger("to_i").getLongValue());
2693
+ statement.setLong(index, value.convertToInteger("to_i").asLong(context));
2677
2694
  }
2678
2695
  }
2679
2696
 
@@ -2682,14 +2699,14 @@ public class RubyJdbcConnection extends RubyObject {
2682
2699
  final int index, final IRubyObject value,
2683
2700
  final IRubyObject attribute, final int type) throws SQLException {
2684
2701
 
2685
- if ( value instanceof RubyBignum ) {
2686
- setLongOrDecimalParameter(statement, index, ((RubyBignum) value).getValue());
2702
+ if ( value instanceof RubyBignum bignum) {
2703
+ setLongOrDecimalParameter(statement, index, bignum.getValue());
2687
2704
  }
2688
- else if ( value instanceof RubyFixnum ) {
2689
- statement.setLong(index, ((RubyFixnum) value).getLongValue());
2705
+ else if (value instanceof RubyFixnum fixnum) {
2706
+ statement.setLong(index, fixnum.getValue());
2690
2707
  }
2691
2708
  else {
2692
- setLongOrDecimalParameter(statement, index, value.convertToInteger("to_i").getBigIntegerValue());
2709
+ setLongOrDecimalParameter(statement, index, value.convertToInteger("to_i").asBigInteger(context));
2693
2710
  }
2694
2711
  }
2695
2712
 
@@ -2709,11 +2726,11 @@ public class RubyJdbcConnection extends RubyObject {
2709
2726
  final int index, final IRubyObject value,
2710
2727
  final IRubyObject attribute, final int type) throws SQLException {
2711
2728
 
2712
- if ( value instanceof RubyNumeric ) {
2713
- statement.setDouble(index, ((RubyNumeric) value).getDoubleValue());
2729
+ if ( value instanceof RubyNumeric numeric) {
2730
+ statement.setDouble(index, numeric.asDouble(context));
2714
2731
  }
2715
2732
  else {
2716
- statement.setDouble(index, value.convertToFloat().getDoubleValue());
2733
+ statement.setDouble(index, value.convertToFloat().asDouble(context));
2717
2734
  }
2718
2735
  }
2719
2736
 
@@ -2722,19 +2739,18 @@ public class RubyJdbcConnection extends RubyObject {
2722
2739
  final int index, final IRubyObject value,
2723
2740
  final IRubyObject attribute, final int type) throws SQLException {
2724
2741
 
2725
- if (value instanceof RubyBigDecimal) {
2726
- statement.setBigDecimal(index, ((RubyBigDecimal) value).getValue());
2742
+ if (value instanceof RubyBigDecimal bigdecimal) {
2743
+ statement.setBigDecimal(index, bigdecimal.getValue());
2727
2744
  }
2728
- else if ( value instanceof RubyInteger ) {
2729
- statement.setBigDecimal(index, new BigDecimal(((RubyInteger) value).getBigIntegerValue()));
2745
+ else if ( value instanceof RubyInteger integer) {
2746
+ statement.setBigDecimal(index, new BigDecimal(integer.asBigInteger(context)));
2730
2747
  }
2731
- else if ( value instanceof RubyNumeric ) {
2732
- statement.setDouble(index, ((RubyNumeric) value).getDoubleValue());
2748
+ else if ( value instanceof RubyNumeric numeric) {
2749
+ statement.setDouble(index, numeric.asDouble(context));
2733
2750
  }
2734
2751
  else { // e.g. `BigDecimal '42.00000000000000000001'`
2735
- Ruby runtime = context.runtime;
2736
2752
  statement.setBigDecimal(index,
2737
- RubyBigDecimal.newInstance(context, runtime.getModule("BigDecimal"), value, RubyFixnum.zero(runtime)).getValue());
2753
+ RubyBigDecimal.newInstance(context, getModule(context, "BigDecimal"), value, asFixnum(context, 0)).getValue());
2738
2754
  }
2739
2755
  }
2740
2756
 
@@ -2793,7 +2809,7 @@ public class RubyJdbcConnection extends RubyObject {
2793
2809
  final int index, IRubyObject value,
2794
2810
  final IRubyObject attribute, final int type) throws SQLException {
2795
2811
 
2796
- if ( ! "Date".equals(value.getMetaClass().getName()) && value.respondsTo("to_date") ) {
2812
+ if ( ! "Date".equals(value.getMetaClass().getName(context)) && value.respondsTo("to_date") ) {
2797
2813
  value = value.callMethod(context, "to_date");
2798
2814
  }
2799
2815
 
@@ -2920,7 +2936,7 @@ public class RubyJdbcConnection extends RubyObject {
2920
2936
  protected Connection getConnectionInternal(final boolean required) throws SQLException {
2921
2937
  Connection connection = getConnectionImpl();
2922
2938
  if (connection == null && required) {
2923
- if (!connected) handleNotConnected(); // raise ConnectionNotEstablished
2939
+ if (!connected) handleNotConnected(getRuntime().getCurrentContext()); // raise ConnectionNotEstablished
2924
2940
  synchronized (this) {
2925
2941
  connection = getConnectionImpl();
2926
2942
  if ( connection == null ) {
@@ -2932,10 +2948,9 @@ public class RubyJdbcConnection extends RubyObject {
2932
2948
  return connection;
2933
2949
  }
2934
2950
 
2935
- private void handleNotConnected() {
2936
- final Ruby runtime = getRuntime();
2937
- final RubyClass errorClass = getConnectionNotEstablished( runtime );
2938
- throw runtime.newRaiseException(errorClass, "no connection available");
2951
+ private void handleNotConnected(ThreadContext context) {
2952
+ final RubyClass errorClass = getConnectionNotEstablished(context);
2953
+ throw context.runtime.newRaiseException(errorClass, "no connection available");
2939
2954
  }
2940
2955
 
2941
2956
  /**
@@ -3001,7 +3016,7 @@ public class RubyJdbcConnection extends RubyObject {
3001
3016
  protected int getAliveTimeout(final ThreadContext context) {
3002
3017
  if ( aliveTimeout == Integer.MIN_VALUE ) {
3003
3018
  final IRubyObject timeout = getConfigValue(context, "connection_alive_timeout");
3004
- return aliveTimeout = timeout == context.nil ? 0 : RubyInteger.fix2int(timeout);
3019
+ aliveTimeout = timeout == context.nil ? 0 : toInt(context, timeout);
3005
3020
  }
3006
3021
  return aliveTimeout;
3007
3022
  }
@@ -3018,7 +3033,7 @@ public class RubyJdbcConnection extends RubyObject {
3018
3033
  @Override
3019
3034
  @JRubyMethod
3020
3035
  @SuppressWarnings("unchecked")
3021
- public IRubyObject inspect() {
3036
+ public IRubyObject inspect(ThreadContext context) {
3022
3037
  final ArrayList<Variable<String>> varList = new ArrayList<>(2);
3023
3038
  final Connection connection = getConnectionImpl();
3024
3039
  varList.add(new VariableEntry<>( "connection", connection == null ? "null" : connection.toString() ));
@@ -3074,10 +3089,10 @@ public class RubyJdbcConnection extends RubyObject {
3074
3089
  protected RubyArray mapTables(final ThreadContext context, final Connection connection,
3075
3090
  final String catalog, final String schemaPattern, final String tablePattern,
3076
3091
  final ResultSet tablesSet) throws SQLException {
3077
- final RubyArray tables = RubyArray.newArray(context.runtime);
3092
+ final RubyArray tables = newArray(context);
3078
3093
  while ( tablesSet.next() ) {
3079
3094
  String name = tablesSet.getString(TABLES_TABLE_NAME);
3080
- tables.append( cachedString(context, caseConvertIdentifierForRails(connection, name)) );
3095
+ tables.append(context, cachedString(context, caseConvertIdentifierForRails(connection, name)));
3081
3096
  }
3082
3097
  return tables;
3083
3098
  }
@@ -3141,7 +3156,7 @@ public class RubyJdbcConnection extends RubyObject {
3141
3156
 
3142
3157
  final Ruby runtime = context.runtime;
3143
3158
 
3144
- final RubyArray columns = RubyArray.newArray(runtime);
3159
+ final RubyArray columns = newArray(context);
3145
3160
  while ( results.next() ) {
3146
3161
  final String colName = results.getString(COLUMN_NAME);
3147
3162
  final RubyString columnName = cachedString(context, caseConvertIdentifierForRails(metaData, colName));
@@ -3158,7 +3173,7 @@ public class RubyJdbcConnection extends RubyObject {
3158
3173
  final IRubyObject[] args = new IRubyObject[] {
3159
3174
  columnName, defaultValue, type_metadata, nullable, tableName
3160
3175
  };
3161
- columns.append( Column.newInstance(context, args, Block.NULL_BLOCK) );
3176
+ columns.append(context, Column.newInstance(context, args, Block.NULL_BLOCK));
3162
3177
  }
3163
3178
  return columns;
3164
3179
  }
@@ -3188,7 +3203,7 @@ public class RubyJdbcConnection extends RubyObject {
3188
3203
  }
3189
3204
 
3190
3205
  protected IRubyObject mapGeneratedKeys(
3191
- final Ruby runtime, final Connection connection,
3206
+ ThreadContext context, final Connection connection,
3192
3207
  final Statement statement, final Boolean singleResult)
3193
3208
  throws SQLException {
3194
3209
  if ( supportsGeneratedKeys(connection) ) {
@@ -3197,8 +3212,8 @@ public class RubyJdbcConnection extends RubyObject {
3197
3212
  genKeys = statement.getGeneratedKeys();
3198
3213
  // drivers might report a non-result statement without keys
3199
3214
  // e.g. on derby with SQL: 'SET ISOLATION = SERIALIZABLE'
3200
- if ( genKeys == null ) return runtime.getNil();
3201
- return doMapGeneratedKeys(runtime, genKeys, singleResult);
3215
+ if ( genKeys == null ) return context.nil;
3216
+ return doMapGeneratedKeys(context, genKeys, singleResult);
3202
3217
  }
3203
3218
  catch (SQLFeatureNotSupportedException e) {
3204
3219
  return null; // statement.getGeneratedKeys()
@@ -3208,7 +3223,7 @@ public class RubyJdbcConnection extends RubyObject {
3208
3223
  return null; // not supported
3209
3224
  }
3210
3225
 
3211
- protected final IRubyObject doMapGeneratedKeys(final Ruby runtime,
3226
+ protected final IRubyObject doMapGeneratedKeys(ThreadContext context,
3212
3227
  final ResultSet genKeys, final Boolean singleResult)
3213
3228
  throws SQLException {
3214
3229
 
@@ -3219,28 +3234,28 @@ public class RubyJdbcConnection extends RubyObject {
3219
3234
  // singleResult == null - guess if only single key returned
3220
3235
  if ( singleResult == null || singleResult) {
3221
3236
  if ( next ) {
3222
- firstKey = mapGeneratedKey(runtime, genKeys);
3237
+ firstKey = mapGeneratedKey(context, genKeys);
3223
3238
  if ( singleResult != null || ! genKeys.next() ) {
3224
3239
  return firstKey;
3225
3240
  }
3226
3241
  next = true; // 2nd genKeys.next() returned true
3227
3242
  }
3228
3243
  else {
3229
- /* if ( singleResult != null ) */ return runtime.getNil();
3244
+ /* if ( singleResult != null ) */ return context.nil;
3230
3245
  }
3231
3246
  }
3232
3247
 
3233
- final RubyArray keys = runtime.newArray();
3234
- if ( firstKey != null ) keys.append(firstKey); // singleResult == null
3248
+ final RubyArray keys = newArray(context);
3249
+ if (firstKey != null) keys.append(context, firstKey); // singleResult == null
3235
3250
  while ( next ) {
3236
- keys.append( mapGeneratedKey(runtime, genKeys) );
3251
+ keys.append(context, mapGeneratedKey(context, genKeys));
3237
3252
  next = genKeys.next();
3238
3253
  }
3239
3254
  return keys;
3240
3255
  }
3241
3256
 
3242
- protected IRubyObject mapGeneratedKey(final Ruby runtime, final ResultSet genKeys) throws SQLException {
3243
- return runtime.newFixnum(genKeys.getLong(1));
3257
+ protected IRubyObject mapGeneratedKey(ThreadContext context, final ResultSet genKeys) throws SQLException {
3258
+ return asFixnum(context, genKeys.getLong(1));
3244
3259
  }
3245
3260
 
3246
3261
  private transient Boolean supportsGeneratedKeys;
@@ -3248,7 +3263,7 @@ public class RubyJdbcConnection extends RubyObject {
3248
3263
  protected boolean supportsGeneratedKeys(final Connection connection) throws SQLException {
3249
3264
  Boolean supportsGeneratedKeys = this.supportsGeneratedKeys;
3250
3265
  if (supportsGeneratedKeys == null) {
3251
- supportsGeneratedKeys = this.supportsGeneratedKeys = connection.getMetaData().supportsGetGeneratedKeys();
3266
+ supportsGeneratedKeys = this.supportsGeneratedKeys = (Boolean) connection.getMetaData().supportsGetGeneratedKeys();
3252
3267
  }
3253
3268
  return supportsGeneratedKeys;
3254
3269
  }
@@ -3265,12 +3280,11 @@ public class RubyJdbcConnection extends RubyObject {
3265
3280
 
3266
3281
  final ColumnData[] columns = extractColumns(context, connection, resultSet, downCase);
3267
3282
 
3268
- final Ruby runtime = context.runtime;
3269
- final RubyArray results = runtime.newArray();
3283
+ final RubyArray results = newArray(context);
3270
3284
  // [ { 'col1': 1, 'col2': 2 }, { 'col1': 3, 'col2': 4 } ]
3271
3285
 
3272
3286
  while ( resultSet.next() ) {
3273
- results.append(mapRawRow(context, runtime, columns, resultSet, this));
3287
+ results.append(context, mapRawRow(context, context.runtime, columns, resultSet, this));
3274
3288
  }
3275
3289
  return results;
3276
3290
  }
@@ -3341,7 +3355,7 @@ public class RubyJdbcConnection extends RubyObject {
3341
3355
 
3342
3356
  final Connection connection = getConnectionInternal(false); // getConnection()
3343
3357
  if ( connection == null ) {
3344
- if ( ! connected ) handleNotConnected(); // raise ConnectionNotEstablished
3358
+ if ( ! connected ) handleNotConnected(context); // raise ConnectionNotEstablished
3345
3359
  throw new NoConnectionException();
3346
3360
  }
3347
3361
  gotConnection = true;
@@ -3455,7 +3469,7 @@ public class RubyJdbcConnection extends RubyObject {
3455
3469
  return wrapException(context, context.runtime.getRuntimeError(), exception);
3456
3470
  }
3457
3471
  // NOTE: compat - maybe makes sense or maybe not (e.g. IOException) :
3458
- return wrapException(context, getJDBCError(runtime), exception);
3472
+ return wrapException(context, getJDBCError(context), exception);
3459
3473
  }
3460
3474
 
3461
3475
  public static RaiseException wrapException(final ThreadContext context,
@@ -3471,7 +3485,7 @@ public class RubyJdbcConnection extends RubyObject {
3471
3485
  }
3472
3486
 
3473
3487
  protected RaiseException wrapException(final ThreadContext context, final SQLException exception, String message) {
3474
- return wrapSQLException(context, getJDBCError(context.runtime), exception, message);
3488
+ return wrapSQLException(context, getJDBCError(context), exception, message);
3475
3489
  }
3476
3490
 
3477
3491
  protected RaiseException wrapException(final ThreadContext context, final RubyClass errorClass, final SQLException exception) {
@@ -3492,8 +3506,8 @@ public class RubyJdbcConnection extends RubyObject {
3492
3506
  }
3493
3507
 
3494
3508
  protected final RaiseException newNoDatabaseError(final SQLException ex) {
3495
- final Ruby runtime = getRuntime();
3496
- return wrapException(runtime.getCurrentContext(), getNoDatabaseError(runtime), ex);
3509
+ var context = getRuntime().getCurrentContext();
3510
+ return wrapException(context, getNoDatabaseError(context), ex);
3497
3511
  }
3498
3512
 
3499
3513
  private IRubyObject convertJavaToRuby(final Object object) {
@@ -3552,14 +3566,14 @@ public class RubyJdbcConnection extends RubyObject {
3552
3566
  row[i] = connection.jdbcToRuby(context, runtime, column.index, column.type, resultSet);
3553
3567
  }
3554
3568
 
3555
- return RubyArray.newArrayNoCopy(context.runtime, row);
3569
+ return newArrayNoCopy(context, row);
3556
3570
  }
3557
3571
 
3558
3572
  private static IRubyObject mapRawRow(final ThreadContext context, final Ruby runtime,
3559
3573
  final ColumnData[] columns, final ResultSet resultSet,
3560
3574
  final RubyJdbcConnection connection) throws SQLException {
3561
3575
 
3562
- final RubyHash row = new RubyHash(runtime, columns.length);
3576
+ final RubyHash row = RubyHash.newHash(runtime);
3563
3577
 
3564
3578
  for ( int i = 0; i < columns.length; i++ ) {
3565
3579
  final ColumnData column = columns[i];
@@ -3573,13 +3587,13 @@ public class RubyJdbcConnection extends RubyObject {
3573
3587
  }
3574
3588
 
3575
3589
  protected static IRubyObject newResult(final ThreadContext context, ColumnData[] columns, IRubyObject rows) {
3576
- final RubyClass Result = getResult(context.runtime);
3590
+ final RubyClass Result = getResult(context);
3577
3591
  return Result.newInstance(context, columnsToArray(context, columns), rows, Block.NULL_BLOCK); // Result.new
3578
3592
  }
3579
3593
 
3580
3594
  protected static IRubyObject newEmptyResult(final ThreadContext context) {
3581
- final RubyClass Result = getResult(context.runtime);
3582
- return Result.newInstance(context, RubyArray.newEmptyArray(context.runtime), RubyArray.newEmptyArray(context.runtime), Block.NULL_BLOCK); // Result.new
3595
+ final RubyClass Result = getResult(context);
3596
+ return Result.newInstance(context, newEmptyArray(context), newEmptyArray(context), Block.NULL_BLOCK); // Result.new
3583
3597
  }
3584
3598
 
3585
3599
  private static RubyArray columnsToArray(ThreadContext context, ColumnData[] columns) {
@@ -3587,7 +3601,7 @@ public class RubyJdbcConnection extends RubyObject {
3587
3601
 
3588
3602
  for ( int i = 0; i < columns.length; i++ ) cols[i] = columns[i].getName(context);
3589
3603
 
3590
- return RubyArray.newArrayNoCopy(context.runtime, cols);
3604
+ return newArrayNoCopy(context, cols);
3591
3605
  }
3592
3606
 
3593
3607
  protected static final class TableName {