neo-activerecord-jdbc-adapter 5.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +33 -0
  3. data/.travis.yml +438 -0
  4. data/.yardopts +4 -0
  5. data/Appraisals +41 -0
  6. data/CONTRIBUTING.md +44 -0
  7. data/Gemfile +62 -0
  8. data/History.md +1191 -0
  9. data/LICENSE.txt +25 -0
  10. data/README.md +266 -0
  11. data/RUNNING_TESTS.md +88 -0
  12. data/Rakefile +100 -0
  13. data/Rakefile.jdbc +20 -0
  14. data/activerecord-jdbc-adapter.gemspec +42 -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 +60 -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 +19 -0
  43. data/lib/arjdbc/abstract/database_statements.rb +92 -0
  44. data/lib/arjdbc/abstract/transaction_support.rb +86 -0
  45. data/lib/arjdbc/common_jdbc_methods.rb +13 -0
  46. data/lib/arjdbc/db2.rb +4 -0
  47. data/lib/arjdbc/db2/adapter.rb +789 -0
  48. data/lib/arjdbc/db2/as400.rb +130 -0
  49. data/lib/arjdbc/db2/column.rb +167 -0
  50. data/lib/arjdbc/db2/connection_methods.rb +44 -0
  51. data/lib/arjdbc/derby.rb +3 -0
  52. data/lib/arjdbc/derby/active_record_patch.rb +13 -0
  53. data/lib/arjdbc/derby/adapter.rb +556 -0
  54. data/lib/arjdbc/derby/connection_methods.rb +20 -0
  55. data/lib/arjdbc/derby/schema_creation.rb +15 -0
  56. data/lib/arjdbc/discover.rb +115 -0
  57. data/lib/arjdbc/firebird.rb +4 -0
  58. data/lib/arjdbc/firebird/adapter.rb +434 -0
  59. data/lib/arjdbc/firebird/connection_methods.rb +23 -0
  60. data/lib/arjdbc/h2.rb +3 -0
  61. data/lib/arjdbc/h2/adapter.rb +303 -0
  62. data/lib/arjdbc/h2/connection_methods.rb +27 -0
  63. data/lib/arjdbc/hsqldb.rb +3 -0
  64. data/lib/arjdbc/hsqldb/adapter.rb +297 -0
  65. data/lib/arjdbc/hsqldb/connection_methods.rb +28 -0
  66. data/lib/arjdbc/hsqldb/explain_support.rb +35 -0
  67. data/lib/arjdbc/hsqldb/schema_creation.rb +11 -0
  68. data/lib/arjdbc/informix.rb +5 -0
  69. data/lib/arjdbc/informix/adapter.rb +162 -0
  70. data/lib/arjdbc/informix/connection_methods.rb +9 -0
  71. data/lib/arjdbc/jdbc.rb +59 -0
  72. data/lib/arjdbc/jdbc/adapter.rb +899 -0
  73. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  74. data/lib/arjdbc/jdbc/adapter_require.rb +46 -0
  75. data/lib/arjdbc/jdbc/base_ext.rb +44 -0
  76. data/lib/arjdbc/jdbc/callbacks.rb +51 -0
  77. data/lib/arjdbc/jdbc/column.rb +97 -0
  78. data/lib/arjdbc/jdbc/connection.rb +133 -0
  79. data/lib/arjdbc/jdbc/connection_methods.rb +36 -0
  80. data/lib/arjdbc/jdbc/driver.rb +43 -0
  81. data/lib/arjdbc/jdbc/extension.rb +59 -0
  82. data/lib/arjdbc/jdbc/java.rb +15 -0
  83. data/lib/arjdbc/jdbc/jdbc.rake +4 -0
  84. data/lib/arjdbc/jdbc/quoted_primary_key.rb +28 -0
  85. data/lib/arjdbc/jdbc/railtie.rb +2 -0
  86. data/lib/arjdbc/jdbc/rake_tasks.rb +3 -0
  87. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -0
  88. data/lib/arjdbc/jdbc/type_cast.rb +166 -0
  89. data/lib/arjdbc/jdbc/type_converter.rb +142 -0
  90. data/lib/arjdbc/mimer.rb +3 -0
  91. data/lib/arjdbc/mimer/adapter.rb +142 -0
  92. data/lib/arjdbc/mssql.rb +7 -0
  93. data/lib/arjdbc/mssql/adapter.rb +808 -0
  94. data/lib/arjdbc/mssql/column.rb +200 -0
  95. data/lib/arjdbc/mssql/connection_methods.rb +79 -0
  96. data/lib/arjdbc/mssql/explain_support.rb +99 -0
  97. data/lib/arjdbc/mssql/limit_helpers.rb +231 -0
  98. data/lib/arjdbc/mssql/lock_methods.rb +77 -0
  99. data/lib/arjdbc/mssql/types.rb +343 -0
  100. data/lib/arjdbc/mssql/utils.rb +82 -0
  101. data/lib/arjdbc/mysql.rb +3 -0
  102. data/lib/arjdbc/mysql/adapter.rb +1006 -0
  103. data/lib/arjdbc/mysql/bulk_change_table.rb +150 -0
  104. data/lib/arjdbc/mysql/column.rb +162 -0
  105. data/lib/arjdbc/mysql/connection_methods.rb +145 -0
  106. data/lib/arjdbc/mysql/explain_support.rb +82 -0
  107. data/lib/arjdbc/mysql/schema_creation.rb +58 -0
  108. data/lib/arjdbc/oracle.rb +4 -0
  109. data/lib/arjdbc/oracle/adapter.rb +952 -0
  110. data/lib/arjdbc/oracle/column.rb +126 -0
  111. data/lib/arjdbc/oracle/connection_methods.rb +21 -0
  112. data/lib/arjdbc/postgresql.rb +3 -0
  113. data/lib/arjdbc/postgresql/_bc_time_cast_patch.rb +21 -0
  114. data/lib/arjdbc/postgresql/adapter.rb +825 -0
  115. data/lib/arjdbc/postgresql/base/array_decoder.rb +26 -0
  116. data/lib/arjdbc/postgresql/base/array_encoder.rb +25 -0
  117. data/lib/arjdbc/postgresql/base/array_parser.rb +95 -0
  118. data/lib/arjdbc/postgresql/base/pgconn.rb +11 -0
  119. data/lib/arjdbc/postgresql/column.rb +51 -0
  120. data/lib/arjdbc/postgresql/connection_methods.rb +54 -0
  121. data/lib/arjdbc/postgresql/name.rb +24 -0
  122. data/lib/arjdbc/postgresql/oid_types.rb +178 -0
  123. data/lib/arjdbc/railtie.rb +11 -0
  124. data/lib/arjdbc/sqlite3.rb +3 -0
  125. data/lib/arjdbc/sqlite3/adapter.rb +703 -0
  126. data/lib/arjdbc/sqlite3/connection_methods.rb +40 -0
  127. data/lib/arjdbc/sybase.rb +2 -0
  128. data/lib/arjdbc/sybase/adapter.rb +47 -0
  129. data/lib/arjdbc/tasks.rb +13 -0
  130. data/lib/arjdbc/tasks/database_tasks.rb +54 -0
  131. data/lib/arjdbc/tasks/databases.rake +91 -0
  132. data/lib/arjdbc/tasks/databases3.rake +215 -0
  133. data/lib/arjdbc/tasks/databases4.rake +39 -0
  134. data/lib/arjdbc/tasks/db2_database_tasks.rb +104 -0
  135. data/lib/arjdbc/tasks/derby_database_tasks.rb +95 -0
  136. data/lib/arjdbc/tasks/h2_database_tasks.rb +31 -0
  137. data/lib/arjdbc/tasks/hsqldb_database_tasks.rb +70 -0
  138. data/lib/arjdbc/tasks/jdbc_database_tasks.rb +169 -0
  139. data/lib/arjdbc/tasks/mssql_database_tasks.rb +46 -0
  140. data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +297 -0
  141. data/lib/arjdbc/tasks/oracle_database_tasks.rb +65 -0
  142. data/lib/arjdbc/util/quoted_cache.rb +60 -0
  143. data/lib/arjdbc/util/serialized_attributes.rb +98 -0
  144. data/lib/arjdbc/util/table_copier.rb +110 -0
  145. data/lib/arjdbc/version.rb +8 -0
  146. data/lib/generators/jdbc/USAGE +9 -0
  147. data/lib/generators/jdbc/jdbc_generator.rb +17 -0
  148. data/lib/jdbc_adapter.rb +2 -0
  149. data/lib/jdbc_adapter/rake_tasks.rb +4 -0
  150. data/lib/jdbc_adapter/version.rb +4 -0
  151. data/pom.xml +114 -0
  152. data/rails_generators/jdbc_generator.rb +15 -0
  153. data/rails_generators/templates/config/initializers/jdbc.rb +10 -0
  154. data/rails_generators/templates/lib/tasks/jdbc.rake +11 -0
  155. data/rakelib/01-tomcat.rake +51 -0
  156. data/rakelib/02-test.rake +121 -0
  157. data/rakelib/bundler_ext.rb +11 -0
  158. data/rakelib/compile.rake +62 -0
  159. data/rakelib/db.rake +58 -0
  160. data/rakelib/rails.rake +75 -0
  161. data/src/java/arjdbc/ArJdbcModule.java +178 -0
  162. data/src/java/arjdbc/db2/DB2Module.java +71 -0
  163. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +142 -0
  164. data/src/java/arjdbc/derby/DerbyModule.java +179 -0
  165. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +164 -0
  166. data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +190 -0
  167. data/src/java/arjdbc/h2/H2Module.java +44 -0
  168. data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +67 -0
  169. data/src/java/arjdbc/hsqldb/HSQLDBModule.java +68 -0
  170. data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +75 -0
  171. data/src/java/arjdbc/jdbc/AdapterJavaService.java +45 -0
  172. data/src/java/arjdbc/jdbc/Callable.java +44 -0
  173. data/src/java/arjdbc/jdbc/JdbcConnectionFactory.java +45 -0
  174. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +3616 -0
  175. data/src/java/arjdbc/jdbc/SQLBlock.java +54 -0
  176. data/src/java/arjdbc/mssql/MSSQLModule.java +102 -0
  177. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +195 -0
  178. data/src/java/arjdbc/mysql/MySQLModule.java +147 -0
  179. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +397 -0
  180. data/src/java/arjdbc/oracle/OracleModule.java +75 -0
  181. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +465 -0
  182. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +752 -0
  183. data/src/java/arjdbc/sqlite3/SQLite3Module.java +78 -0
  184. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +351 -0
  185. data/src/java/arjdbc/util/CallResultSet.java +826 -0
  186. data/src/java/arjdbc/util/QuotingUtils.java +111 -0
  187. metadata +255 -0
@@ -0,0 +1,78 @@
1
+ /*
2
+ * The MIT License
3
+ *
4
+ * Copyright 2013 Karol Bucek.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+ package arjdbc.sqlite3;
25
+
26
+ import static arjdbc.util.QuotingUtils.quoteCharWith;
27
+
28
+ import org.jruby.RubyModule;
29
+ import org.jruby.RubyString;
30
+ import org.jruby.anno.JRubyMethod;
31
+ import org.jruby.runtime.ThreadContext;
32
+ import org.jruby.runtime.builtin.IRubyObject;
33
+ import org.jruby.util.ByteList;
34
+
35
+ /**
36
+ * ArJdbc::SQLite3
37
+ *
38
+ * @author kares
39
+ */
40
+ public class SQLite3Module {
41
+
42
+ public static RubyModule load(final RubyModule arJdbc) {
43
+ RubyModule sqlite3 = arJdbc.defineModuleUnder("SQLite3");
44
+ sqlite3.defineAnnotatedMethods( SQLite3Module.class );
45
+ return sqlite3;
46
+ }
47
+
48
+ @JRubyMethod(name = "quote_string", required = 1, frame = false)
49
+ public static IRubyObject quote_string(
50
+ final ThreadContext context,
51
+ final IRubyObject self,
52
+ final IRubyObject string) { // string.gsub("'", "''") :
53
+ final char single = '\'';
54
+ final RubyString quoted = quoteCharWith(
55
+ context, (RubyString) string, single, single
56
+ );
57
+ return quoted;
58
+ }
59
+
60
+ private static final ByteList Q_TRUE = new ByteList(new byte[] { '\'', 't', '\'' }, false);
61
+
62
+ @JRubyMethod(name = "quoted_true", required = 0, frame = false)
63
+ public static IRubyObject quoted_true(
64
+ final ThreadContext context,
65
+ final IRubyObject self) {
66
+ return RubyString.newString(context.getRuntime(), Q_TRUE);
67
+ }
68
+
69
+ private static final ByteList Q_FALSE = new ByteList(new byte[] { '\'', 'f', '\'' }, false);
70
+
71
+ @JRubyMethod(name = "quoted_false", required = 0, frame = false)
72
+ public static IRubyObject quoted_false(
73
+ final ThreadContext context,
74
+ final IRubyObject self) {
75
+ return RubyString.newString(context.getRuntime(), Q_FALSE);
76
+ }
77
+
78
+ }
@@ -0,0 +1,351 @@
1
+ /***** BEGIN LICENSE BLOCK *****
2
+ * Copyright (c) 2012-2013 Karol Bucek <self@kares.org>
3
+ * Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
4
+ * Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
5
+ * Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining
8
+ * a copy of this software and associated documentation files (the
9
+ * "Software"), to deal in the Software without restriction, including
10
+ * without limitation the rights to use, copy, modify, merge, publish,
11
+ * distribute, sublicense, and/or sell copies of the Software, and to
12
+ * permit persons to whom the Software is furnished to do so, subject to
13
+ * the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+ ***** END LICENSE BLOCK *****/
26
+
27
+ package arjdbc.sqlite3;
28
+
29
+ import arjdbc.jdbc.Callable;
30
+ import arjdbc.jdbc.RubyJdbcConnection;
31
+
32
+ import java.io.IOException;
33
+ import java.sql.Connection;
34
+ import java.sql.ResultSet;
35
+ import java.sql.ResultSetMetaData;
36
+ import java.sql.SQLException;
37
+ import java.sql.Statement;
38
+ import java.sql.DatabaseMetaData;
39
+ import java.sql.Savepoint;
40
+ import java.sql.Types;
41
+ import java.util.ArrayList;
42
+ import java.util.List;
43
+
44
+ import org.jruby.Ruby;
45
+ import org.jruby.RubyArray;
46
+ import org.jruby.RubyClass;
47
+ import org.jruby.RubyString;
48
+ import org.jruby.anno.JRubyMethod;
49
+ import org.jruby.runtime.ObjectAllocator;
50
+ import org.jruby.runtime.ThreadContext;
51
+ import org.jruby.runtime.builtin.IRubyObject;
52
+ import org.jruby.util.ByteList;
53
+
54
+ /**
55
+ *
56
+ * @author enebo
57
+ */
58
+ public class SQLite3RubyJdbcConnection extends RubyJdbcConnection {
59
+ private static final long serialVersionUID = -5783855018818472773L;
60
+
61
+ protected SQLite3RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
62
+ super(runtime, metaClass);
63
+ }
64
+
65
+ public static RubyClass createSQLite3JdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
66
+ final RubyClass clazz = getConnectionAdapters(runtime). // ActiveRecord::ConnectionAdapters
67
+ defineClassUnder("SQLite3JdbcConnection", jdbcConnection, SQLITE3_JDBCCONNECTION_ALLOCATOR);
68
+ clazz.defineAnnotatedMethods( SQLite3RubyJdbcConnection.class );
69
+ getConnectionAdapters(runtime).setConstant("Sqlite3JdbcConnection", clazz); // backwards-compat
70
+ return clazz;
71
+ }
72
+
73
+ private static ObjectAllocator SQLITE3_JDBCCONNECTION_ALLOCATOR = new ObjectAllocator() {
74
+ public IRubyObject allocate(Ruby runtime, RubyClass klass) {
75
+ return new SQLite3RubyJdbcConnection(runtime, klass);
76
+ }
77
+ };
78
+
79
+ @JRubyMethod(name = {"last_insert_rowid", "last_insert_id"}, alias = "last_insert_row_id")
80
+ public IRubyObject last_insert_rowid(final ThreadContext context)
81
+ throws SQLException {
82
+ return withConnection(context, new Callable<IRubyObject>() {
83
+ public IRubyObject call(final Connection connection) throws SQLException {
84
+ Statement statement = null; ResultSet genKeys = null;
85
+ try {
86
+ statement = connection.createStatement();
87
+ // NOTE: strangely this will work and has been used for quite some time :
88
+ //return mapGeneratedKeys(context.getRuntime(), connection, statement, true);
89
+ // but we should assume SQLite JDBC will prefer sane API usage eventually :
90
+ genKeys = statement.executeQuery("SELECT last_insert_rowid()");
91
+ return doMapGeneratedKeys(context.getRuntime(), genKeys, true);
92
+ }
93
+ catch (final SQLException e) {
94
+ debugMessage(context, "failed to get generated keys: " + e.getMessage());
95
+ throw e;
96
+ }
97
+ finally { close(genKeys); close(statement); }
98
+ }
99
+ });
100
+ }
101
+
102
+ // NOTE: interestingly it supports getGeneratedKeys but not executeUpdate
103
+ // + the driver does not report it supports it via the meta-data yet does
104
+ @Override
105
+ protected boolean supportsGeneratedKeys(final Connection connection) throws SQLException {
106
+ return true;
107
+ }
108
+
109
+ @Override
110
+ protected Statement createStatement(final ThreadContext context, final Connection connection)
111
+ throws SQLException {
112
+ final Statement statement = connection.createStatement();
113
+ IRubyObject statementEscapeProcessing = getConfigValue(context, "statement_escape_processing");
114
+ if ( ! statementEscapeProcessing.isNil() ) {
115
+ statement.setEscapeProcessing(statementEscapeProcessing.isTrue());
116
+ }
117
+ // else leave as is by default
118
+ return statement;
119
+ }
120
+
121
+ @Override
122
+ protected IRubyObject indexes(final ThreadContext context, String table, final String name, String schema) {
123
+ if ( table != null ) {
124
+ final int i = table.indexOf('.');
125
+ if ( i > 0 && schema == null ) {
126
+ schema = table.substring(0, i);
127
+ table = table.substring(i + 1);
128
+ }
129
+ }
130
+ final String tableName = table;
131
+ final String schemaName = schema;
132
+ // return super.indexes(context, tableName, name, schemaName);
133
+ return withConnection(context, new Callable<IRubyObject>() {
134
+ public RubyArray call(final Connection connection) throws SQLException {
135
+ final Ruby runtime = context.runtime;
136
+ final RubyClass indexDefinition = getIndexDefinition(runtime);
137
+
138
+ final TableName table = extractTableName(connection, null, schemaName, tableName);
139
+
140
+ final List<RubyString> primaryKeys = primaryKeys(context, connection, table);
141
+
142
+ final DatabaseMetaData metaData = connection.getMetaData();
143
+ ResultSet indexInfoSet = null;
144
+ try {
145
+ indexInfoSet = metaData.getIndexInfo(table.catalog, table.schema, table.name, false, true);
146
+ }
147
+ catch (SQLException e) {
148
+ final String msg = e.getMessage();
149
+ if ( msg != null && msg.startsWith("[SQLITE_ERROR] SQL error or missing database") ) {
150
+ return RubyArray.newEmptyArray(runtime); // on 3.8.7 getIndexInfo fails if table has no indexes
151
+ }
152
+ throw e;
153
+ }
154
+ final RubyArray indexes = RubyArray.newArray(runtime, 8);
155
+ try {
156
+ String currentIndex = null;
157
+
158
+ while ( indexInfoSet.next() ) {
159
+ String indexName = indexInfoSet.getString(INDEX_INFO_NAME);
160
+ if ( indexName == null ) continue;
161
+
162
+ final String columnName = indexInfoSet.getString(INDEX_INFO_COLUMN_NAME);
163
+ final RubyString rubyColumnName = RubyString.newUnicodeString(runtime, columnName);
164
+ if ( primaryKeys.contains(rubyColumnName) ) continue;
165
+
166
+ // We are working on a new index
167
+ if ( ! indexName.equals(currentIndex) ) {
168
+ currentIndex = indexName;
169
+
170
+ String indexTableName = indexInfoSet.getString(INDEX_INFO_TABLE_NAME);
171
+
172
+ final boolean nonUnique = indexInfoSet.getBoolean(INDEX_INFO_NON_UNIQUE);
173
+
174
+ IRubyObject[] args = new IRubyObject[] {
175
+ RubyString.newUnicodeString(runtime, indexTableName), // table_name
176
+ RubyString.newUnicodeString(runtime, indexName), // index_name
177
+ runtime.newBoolean( ! nonUnique ), // unique
178
+ runtime.newArray() // [] for column names, we'll add to that in just a bit
179
+ // orders, (since AR 3.2) where, type, using (AR 4.0)
180
+ };
181
+
182
+ indexes.append( indexDefinition.callMethod(context, "new", args) ); // IndexDefinition.new
183
+ }
184
+
185
+ // One or more columns can be associated with an index
186
+ IRubyObject lastIndexDef = indexes.isEmpty() ? null : indexes.entry(-1);
187
+ if ( lastIndexDef != null ) {
188
+ ( (RubyArray) lastIndexDef.callMethod(context, "columns") ).append(rubyColumnName);
189
+ }
190
+ }
191
+
192
+ return indexes;
193
+
194
+ } finally { close(indexInfoSet); }
195
+ }
196
+ });
197
+ }
198
+
199
+ @Override
200
+ protected TableName extractTableName(
201
+ final Connection connection, String catalog, String schema,
202
+ final String tableName) throws IllegalArgumentException, SQLException {
203
+
204
+ final String[] nameParts = tableName.split("\\.");
205
+ if ( nameParts.length > 3 ) {
206
+ throw new IllegalArgumentException("table name: " + tableName + " should not contain more than 2 '.'");
207
+ }
208
+
209
+ String name = tableName;
210
+
211
+ if ( nameParts.length == 2 ) {
212
+ schema = nameParts[0];
213
+ name = nameParts[1];
214
+ }
215
+ else if ( nameParts.length == 3 ) {
216
+ catalog = nameParts[0];
217
+ schema = nameParts[1];
218
+ name = nameParts[2];
219
+ }
220
+
221
+ if ( schema != null ) {
222
+ // NOTE: hack to work-around SQLite JDBC ignoring schema :
223
+ return new TableName(catalog, null, schema + '.' + name);
224
+ }
225
+ return new TableName(catalog, schema, name);
226
+ }
227
+
228
+ @Override
229
+ protected IRubyObject jdbcToRuby(final ThreadContext context,
230
+ final Ruby runtime, final int column, int type, final ResultSet resultSet)
231
+ throws SQLException {
232
+ // This is rather gross, and only needed because the resultset metadata for SQLite tries to be overly
233
+ // clever, and returns a type for the column of the "current" row, so an integer value stored in a
234
+ // decimal column is returned as Types.INTEGER. Therefore, if the first row of a resultset was an
235
+ // integer value, all rows of that result set would get truncated.
236
+ if ( resultSet instanceof ResultSetMetaData ) {
237
+ type = ((ResultSetMetaData) resultSet).getColumnType(column);
238
+ }
239
+ // since JDBC 3.8 there seems to be more cleverness built-in that
240
+ // seems (<= 3.8.7) to get things wrong ... reports DATE SQL type
241
+ // for "datetime" columns :
242
+ if ( type == Types.DATE ) {
243
+ // return timestampToRuby(context, runtime, resultSet, column);
244
+ return stringToRuby(context, runtime, resultSet, column);
245
+ }
246
+ return super.jdbcToRuby(context, runtime, column, type, resultSet);
247
+ }
248
+
249
+ @Override
250
+ protected IRubyObject streamToRuby(final ThreadContext context,
251
+ final Ruby runtime, final ResultSet resultSet, final int column)
252
+ throws SQLException, IOException {
253
+ final byte[] bytes = resultSet.getBytes(column);
254
+ if ( resultSet.wasNull() ) return runtime.getNil();
255
+ return runtime.newString( new ByteList(bytes, false) );
256
+ }
257
+
258
+ @Override
259
+ protected RubyArray mapTables(final Ruby runtime, final DatabaseMetaData metaData,
260
+ final String catalog, final String schemaPattern, final String tablePattern,
261
+ final ResultSet tablesSet) throws SQLException {
262
+ final List<IRubyObject> tables = new ArrayList<IRubyObject>(32);
263
+ while ( tablesSet.next() ) {
264
+ String name = tablesSet.getString(TABLES_TABLE_NAME);
265
+ name = name.toLowerCase(); // simply lower-case for SQLite3
266
+ tables.add( RubyString.newUnicodeString(runtime, name) );
267
+ }
268
+ return runtime.newArray(tables);
269
+ }
270
+
271
+ private static class SavepointStub implements Savepoint {
272
+
273
+ @Override
274
+ public int getSavepointId() throws SQLException {
275
+ throw new UnsupportedOperationException();
276
+ }
277
+
278
+ @Override
279
+ public String getSavepointName() throws SQLException {
280
+ throw new UnsupportedOperationException();
281
+ }
282
+
283
+ }
284
+
285
+ @Override
286
+ public IRubyObject begin(ThreadContext context, IRubyObject level) {
287
+ throw context.runtime.newRaiseException(ActiveRecord(context).getClass("TransactionIsolationError"),
288
+ "SQLite3 does not support isolation levels");
289
+ }
290
+
291
+ @Override
292
+ @JRubyMethod(name = "create_savepoint", optional = 1)
293
+ public IRubyObject create_savepoint(final ThreadContext context, final IRubyObject[] args) {
294
+ final IRubyObject name = args.length > 0 ? args[0] : null;
295
+ if ( name == null || name.isNil() ) {
296
+ throw new IllegalArgumentException("create_savepoint (without name) not implemented!");
297
+ }
298
+ final Connection connection = getConnection(context, true);
299
+ try {
300
+ connection.setAutoCommit(false);
301
+ // NOTE: JDBC driver does not support setSavepoint(String) :
302
+ connection.createStatement().execute("SAVEPOINT " + name.toString());
303
+
304
+ getSavepoints(context).put(name, new SavepointStub());
305
+
306
+ return name;
307
+ }
308
+ catch (SQLException e) {
309
+ return handleException(context, e);
310
+ }
311
+ }
312
+
313
+ @Override
314
+ @JRubyMethod(name = "rollback_savepoint", required = 1)
315
+ public IRubyObject rollback_savepoint(final ThreadContext context, final IRubyObject name) {
316
+ final Connection connection = getConnection(context, true);
317
+ try {
318
+ if ( getSavepoints(context).get(name) == null ) {
319
+ throw context.getRuntime().newRuntimeError("could not rollback savepoint: '" + name + "' (not set)");
320
+ }
321
+ // NOTE: JDBC driver does not implement rollback(Savepoint) :
322
+ connection.createStatement().execute("ROLLBACK TO SAVEPOINT " + name.toString());
323
+
324
+ return context.getRuntime().getNil();
325
+ }
326
+ catch (SQLException e) {
327
+ return handleException(context, e);
328
+ }
329
+ }
330
+
331
+ // FIXME: Update our JDBC adapter to later version which basically performs this SQL in
332
+ // this method. Then we can use base RubyJdbcConnection version.
333
+ @Override
334
+ @JRubyMethod(name = "release_savepoint", required = 1)
335
+ public IRubyObject release_savepoint(final ThreadContext context, final IRubyObject name) {
336
+ Ruby runtime = context.runtime;
337
+
338
+ try {
339
+ if (getSavepoints(context).remove(name) == null) {
340
+ RubyClass invalidStatement = ActiveRecord(context).getClass("StatementInvalid");
341
+ throw runtime.newRaiseException(invalidStatement, "could not release savepoint: '" + name + "' (not set)");
342
+ }
343
+ // NOTE: JDBC driver does not implement release(Savepoint) :
344
+ getConnection(context, true).createStatement().execute("RELEASE SAVEPOINT " + name.toString());
345
+
346
+ return runtime.getNil();
347
+ } catch (SQLException e) {
348
+ return handleException(context, e);
349
+ }
350
+ }
351
+ }
@@ -0,0 +1,826 @@
1
+ /*
2
+ * The MIT License
3
+ *
4
+ * Copyright 2014 Karol Bucek.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ */
24
+ package arjdbc.util;
25
+
26
+ import java.io.InputStream;
27
+ import java.io.Reader;
28
+ import java.math.BigDecimal;
29
+ import java.net.URL;
30
+ import java.sql.Array;
31
+ import java.sql.Blob;
32
+ import java.sql.CallableStatement;
33
+ import java.sql.Clob;
34
+ import java.sql.Date;
35
+ import java.sql.NClob;
36
+ import java.sql.Ref;
37
+ import java.sql.ResultSet;
38
+ import java.sql.ResultSetMetaData;
39
+ import java.sql.RowId;
40
+ import java.sql.SQLException;
41
+ import java.sql.SQLFeatureNotSupportedException;
42
+ import java.sql.SQLWarning;
43
+ import java.sql.SQLXML;
44
+ import java.sql.Time;
45
+ import java.sql.Timestamp;
46
+ import java.util.Calendar;
47
+ import java.util.Map;
48
+
49
+ /**
50
+ * {@link ResultSet} "emulation" for {@link CallableStatement}.
51
+ *
52
+ * @author kares
53
+ */
54
+ public class CallResultSet implements ResultSet {
55
+
56
+ private final CallableStatement call;
57
+ private final int size; private int row;
58
+
59
+ public CallResultSet(CallableStatement call) {
60
+ this(call, 1);
61
+ }
62
+
63
+ public CallResultSet(CallableStatement call, final int size) {
64
+ this.call = call; this.size = size;
65
+ }
66
+
67
+ public CallableStatement getStatement() {
68
+ return call;
69
+ }
70
+
71
+ @SuppressWarnings("unchecked")
72
+ public <T> T unwrap(Class<T> iface) throws SQLException {
73
+ if ( iface.isAssignableFrom(getClass()) ) return (T) this;
74
+ return call.unwrap(iface);
75
+ }
76
+
77
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
78
+ if ( iface.isAssignableFrom(getClass()) ) return true;
79
+ return call.isWrapperFor(iface);
80
+ }
81
+
82
+ public int getHoldability() {
83
+ return 0;
84
+ // HOLD_CURSORS_OVER_COMMIT = 1
85
+ // CLOSE_CURSORS_AT_COMMIT = 2
86
+ }
87
+
88
+ public boolean isClosed() throws SQLException {
89
+ return call.isClosed();
90
+ }
91
+
92
+ public void close() throws SQLException {
93
+ // NOOP
94
+ }
95
+
96
+ public int getRow() { return row; }
97
+
98
+ public boolean absolute(int row) {
99
+ if ( row < 0 ) row = 0;
100
+ this.row = row; return row <= size && row > 0;
101
+ }
102
+ public boolean relative(int rows) {
103
+ return absolute(this.row + rows);
104
+ }
105
+
106
+ //public boolean next() {
107
+ // return ( ++row <= size );
108
+ //}
109
+
110
+ public boolean next() { return relative(+1); }
111
+ public boolean previous() { return relative(-1); }
112
+
113
+ public boolean first() { return absolute(1); }
114
+ public boolean last() { return absolute(-1); }
115
+
116
+ public boolean isBeforeFirst() { return row <= 0; }
117
+ public boolean isAfterLast() { return row > size; }
118
+
119
+ public boolean isFirst() { return row == 1; }
120
+ public boolean isLast() { return row == size; }
121
+
122
+ public void beforeFirst() { row = 0; }
123
+ public void afterLast() { row = size + 1; }
124
+
125
+ public ResultSetMetaData getMetaData() throws SQLException {
126
+ return call.getMetaData(); // NOTE: should be fine - right?
127
+ }
128
+
129
+ public int findColumn(String columnLabel) throws SQLException {
130
+ getObject(columnLabel); return 1;
131
+ }
132
+
133
+ public void setFetchDirection(int direction) throws SQLException {
134
+ call.setFetchDirection(direction);
135
+ }
136
+
137
+ public int getFetchDirection() throws SQLException {
138
+ return call.getFetchDirection();
139
+ }
140
+
141
+ public void setFetchSize(int rows) throws SQLException {
142
+ // NOOP
143
+ }
144
+
145
+ public int getFetchSize() throws SQLException {
146
+ return 1;
147
+ }
148
+
149
+ public int getType() throws SQLException {
150
+ return TYPE_SCROLL_INSENSITIVE;
151
+ }
152
+
153
+ public int getConcurrency() throws SQLException {
154
+ return CONCUR_READ_ONLY;
155
+ }
156
+
157
+
158
+ public boolean wasNull() throws SQLException {
159
+ return call.wasNull();
160
+ }
161
+
162
+ // GET-ERS :
163
+
164
+ public String getString(int columnIndex) throws SQLException {
165
+ return call.getString(columnIndex);
166
+ }
167
+
168
+ public boolean getBoolean(int columnIndex) throws SQLException {
169
+ return call.getBoolean(columnIndex);
170
+ }
171
+
172
+ public byte getByte(int columnIndex) throws SQLException {
173
+ return call.getByte(columnIndex);
174
+ }
175
+
176
+ public short getShort(int columnIndex) throws SQLException {
177
+ return call.getShort(columnIndex);
178
+ }
179
+
180
+ public int getInt(int columnIndex) throws SQLException {
181
+ return call.getInt(columnIndex);
182
+ }
183
+
184
+ public long getLong(int columnIndex) throws SQLException {
185
+ return call.getLong(columnIndex);
186
+ }
187
+
188
+ public float getFloat(int columnIndex) throws SQLException {
189
+ return call.getFloat(columnIndex);
190
+ }
191
+
192
+ public double getDouble(int columnIndex) throws SQLException {
193
+ return call.getDouble(columnIndex);
194
+ }
195
+
196
+ @SuppressWarnings("deprecation")
197
+ public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
198
+ return call.getBigDecimal(columnIndex, scale);
199
+ }
200
+
201
+ public byte[] getBytes(int columnIndex) throws SQLException {
202
+ return call.getBytes(columnIndex);
203
+ }
204
+
205
+ public Date getDate(int columnIndex) throws SQLException {
206
+ return call.getDate(columnIndex);
207
+ }
208
+
209
+ public Time getTime(int columnIndex) throws SQLException {
210
+ return call.getTime(columnIndex);
211
+ }
212
+
213
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
214
+ return call.getTimestamp(columnIndex);
215
+ }
216
+
217
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
218
+ throw new UnsupportedOperationException("getAsciiStream()");
219
+ }
220
+
221
+ @SuppressWarnings("deprecation")
222
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
223
+ throw new UnsupportedOperationException("getUnicodeStream()");
224
+ }
225
+
226
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
227
+ throw new UnsupportedOperationException("getBinaryStream()");
228
+ }
229
+
230
+ public String getString(String columnLabel) throws SQLException {
231
+ return call.getString(columnLabel);
232
+ }
233
+
234
+ public boolean getBoolean(String columnLabel) throws SQLException {
235
+ return call.getBoolean(columnLabel);
236
+ }
237
+
238
+ public byte getByte(String columnLabel) throws SQLException {
239
+ return call.getByte(columnLabel);
240
+ }
241
+
242
+ public short getShort(String columnLabel) throws SQLException {
243
+ return call.getShort(columnLabel);
244
+ }
245
+
246
+ public int getInt(String columnLabel) throws SQLException {
247
+ return call.getInt(columnLabel);
248
+ }
249
+
250
+ public long getLong(String columnLabel) throws SQLException {
251
+ return call.getLong(columnLabel);
252
+ }
253
+
254
+ public float getFloat(String columnLabel) throws SQLException {
255
+ return call.getFloat(columnLabel);
256
+ }
257
+
258
+ public double getDouble(String columnLabel) throws SQLException {
259
+ return call.getDouble(columnLabel);
260
+ }
261
+
262
+ @SuppressWarnings("deprecation")
263
+ public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
264
+ return call.getBigDecimal(columnLabel);
265
+ }
266
+
267
+ public byte[] getBytes(String columnLabel) throws SQLException {
268
+ return call.getBytes(columnLabel);
269
+ }
270
+
271
+ public Date getDate(String columnLabel) throws SQLException {
272
+ return call.getDate(columnLabel);
273
+ }
274
+
275
+ public Time getTime(String columnLabel) throws SQLException {
276
+ return call.getTime(columnLabel);
277
+ }
278
+
279
+ public Timestamp getTimestamp(String columnLabel) throws SQLException {
280
+ return call.getTimestamp(columnLabel);
281
+ }
282
+
283
+ public InputStream getAsciiStream(String columnLabel) throws SQLException {
284
+ throw new UnsupportedOperationException("getAsciiStream()");
285
+ }
286
+
287
+ @SuppressWarnings("deprecation")
288
+ public InputStream getUnicodeStream(String columnLabel) throws SQLException {
289
+ throw new UnsupportedOperationException("getUnicodeStream()");
290
+ }
291
+
292
+ public InputStream getBinaryStream(String columnLabel) throws SQLException {
293
+ throw new UnsupportedOperationException("getBinaryStream()");
294
+ }
295
+
296
+ public Object getObject(int columnIndex) throws SQLException {
297
+ return call.getObject(columnIndex);
298
+ }
299
+
300
+ public Object getObject(String columnLabel) throws SQLException {
301
+ return call.getObject(columnLabel);
302
+ }
303
+
304
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
305
+ return call.getCharacterStream(columnIndex);
306
+ }
307
+
308
+ public Reader getCharacterStream(String columnLabel) throws SQLException {
309
+ return call.getCharacterStream(columnLabel);
310
+ }
311
+
312
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
313
+ return call.getBigDecimal(columnIndex);
314
+ }
315
+
316
+ public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
317
+ return call.getBigDecimal(columnLabel);
318
+ }
319
+
320
+ public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
321
+ return call.getObject(columnIndex, map);
322
+ }
323
+
324
+ public Ref getRef(int columnIndex) throws SQLException {
325
+ return call.getRef(columnIndex);
326
+ }
327
+
328
+ public Blob getBlob(int columnIndex) throws SQLException {
329
+ return call.getBlob(columnIndex);
330
+ }
331
+
332
+ public Clob getClob(int columnIndex) throws SQLException {
333
+ return call.getClob(columnIndex);
334
+ }
335
+
336
+ public Array getArray(int columnIndex) throws SQLException {
337
+ return call.getArray(columnIndex);
338
+ }
339
+
340
+ public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
341
+ return call.getObject(columnLabel, map);
342
+ }
343
+
344
+ public Ref getRef(String columnLabel) throws SQLException {
345
+ return call.getRef(columnLabel);
346
+ }
347
+
348
+ public Blob getBlob(String columnLabel) throws SQLException {
349
+ return call.getBlob(columnLabel);
350
+ }
351
+
352
+ public Clob getClob(String columnLabel) throws SQLException {
353
+ return call.getClob(columnLabel);
354
+ }
355
+
356
+ public Array getArray(String columnLabel) throws SQLException {
357
+ return call.getArray(columnLabel);
358
+ }
359
+
360
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
361
+ return call.getDate(columnIndex, cal);
362
+ }
363
+
364
+ public Date getDate(String columnLabel, Calendar cal) throws SQLException {
365
+ return call.getDate(columnLabel, cal);
366
+ }
367
+
368
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
369
+ return call.getTime(columnIndex, cal);
370
+ }
371
+
372
+ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
373
+ return call.getTime(columnLabel, cal);
374
+ }
375
+
376
+ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
377
+ return call.getTimestamp(columnIndex, cal);
378
+ }
379
+
380
+ public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException {
381
+ return call.getTimestamp(columnLabel, cal);
382
+ }
383
+
384
+ public URL getURL(int columnIndex) throws SQLException {
385
+ return call.getURL(columnIndex);
386
+ }
387
+
388
+ public URL getURL(String columnLabel) throws SQLException {
389
+ return call.getURL(columnLabel);
390
+ }
391
+
392
+ public RowId getRowId(int columnIndex) throws SQLException {
393
+ return call.getRowId(columnIndex);
394
+ }
395
+
396
+ public RowId getRowId(String columnLabel) throws SQLException {
397
+ return call.getRowId(columnLabel);
398
+ }
399
+
400
+ public NClob getNClob(int columnIndex) throws SQLException {
401
+ return call.getNClob(columnIndex);
402
+ }
403
+
404
+ public NClob getNClob(String columnLabel) throws SQLException {
405
+ return call.getNClob(columnLabel);
406
+ }
407
+
408
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
409
+ return call.getSQLXML(columnIndex);
410
+ }
411
+
412
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
413
+ return call.getSQLXML(columnLabel);
414
+ }
415
+
416
+ public String getNString(int columnIndex) throws SQLException {
417
+ return call.getNString(columnIndex);
418
+ }
419
+
420
+ public String getNString(String columnLabel) throws SQLException {
421
+ return call.getNString(columnLabel);
422
+ }
423
+
424
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
425
+ return call.getNCharacterStream(columnIndex);
426
+ }
427
+
428
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
429
+ return call.getNCharacterStream(columnLabel);
430
+ }
431
+
432
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
433
+ return call.getObject(columnIndex, type);
434
+ }
435
+
436
+ public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
437
+ return call.getObject(columnLabel, type);
438
+ }
439
+
440
+
441
+ // NOT SUPPORTED OPERATIONS :
442
+
443
+
444
+ public SQLWarning getWarnings() throws SQLException {
445
+ return null; // NOOP
446
+ }
447
+
448
+ public void clearWarnings() throws SQLException {
449
+ // NOOP
450
+ }
451
+
452
+ public String getCursorName() throws SQLException {
453
+ return null; // NOOP
454
+ }
455
+
456
+
457
+ public boolean rowUpdated() throws SQLException {
458
+ throw new SQLFeatureNotSupportedException("row updates");
459
+ }
460
+
461
+ public boolean rowInserted() throws SQLException {
462
+ throw new SQLFeatureNotSupportedException("row inserts");
463
+ }
464
+
465
+ public boolean rowDeleted() throws SQLException {
466
+ throw new SQLFeatureNotSupportedException("row deletes");
467
+ }
468
+
469
+ public void insertRow() throws SQLException {
470
+ throw new SQLFeatureNotSupportedException("row inserts");
471
+ }
472
+
473
+ public void updateRow() throws SQLException {
474
+ throw new SQLFeatureNotSupportedException("row updates");
475
+ }
476
+
477
+ public void deleteRow() throws SQLException {
478
+ throw new SQLFeatureNotSupportedException("row deletes");
479
+ }
480
+
481
+ public void refreshRow() throws SQLException {
482
+ // NOOOP
483
+ }
484
+
485
+ public void cancelRowUpdates() throws SQLException {
486
+ // NOOP
487
+ }
488
+
489
+ public void moveToInsertRow() throws SQLException {
490
+ throw new SQLFeatureNotSupportedException();
491
+ }
492
+
493
+ public void moveToCurrentRow() throws SQLException {
494
+ throw new SQLFeatureNotSupportedException();
495
+ }
496
+
497
+
498
+ public void updateNull(int columnIndex) throws SQLException {
499
+ throw new SQLFeatureNotSupportedException("updates");
500
+ }
501
+
502
+ public void updateBoolean(int columnIndex, boolean x) throws SQLException {
503
+ throw new SQLFeatureNotSupportedException("updates");
504
+ }
505
+
506
+ public void updateByte(int columnIndex, byte x) throws SQLException {
507
+ throw new SQLFeatureNotSupportedException("updates");
508
+ }
509
+
510
+ public void updateShort(int columnIndex, short x) throws SQLException {
511
+ throw new SQLFeatureNotSupportedException("updates");
512
+ }
513
+
514
+ public void updateInt(int columnIndex, int x) throws SQLException {
515
+ throw new SQLFeatureNotSupportedException("updates");
516
+ }
517
+
518
+ public void updateLong(int columnIndex, long x) throws SQLException {
519
+ throw new SQLFeatureNotSupportedException("updates");
520
+ }
521
+
522
+ public void updateFloat(int columnIndex, float x) throws SQLException {
523
+ throw new SQLFeatureNotSupportedException("updates");
524
+ }
525
+
526
+ public void updateDouble(int columnIndex, double x) throws SQLException {
527
+ throw new SQLFeatureNotSupportedException("updates");
528
+ }
529
+
530
+ public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
531
+ throw new SQLFeatureNotSupportedException("updates");
532
+ }
533
+
534
+ public void updateString(int columnIndex, String x) throws SQLException {
535
+ throw new SQLFeatureNotSupportedException("updates");
536
+ }
537
+
538
+ public void updateBytes(int columnIndex, byte[] x) throws SQLException {
539
+ throw new SQLFeatureNotSupportedException("updates");
540
+ }
541
+
542
+ public void updateDate(int columnIndex, Date x) throws SQLException {
543
+ throw new SQLFeatureNotSupportedException("updates");
544
+ }
545
+
546
+ public void updateTime(int columnIndex, Time x) throws SQLException {
547
+ throw new SQLFeatureNotSupportedException("updates");
548
+ }
549
+
550
+ public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
551
+ throw new SQLFeatureNotSupportedException("updates");
552
+ }
553
+
554
+ public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
555
+ throw new SQLFeatureNotSupportedException("updates");
556
+ }
557
+
558
+ public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
559
+ throw new SQLFeatureNotSupportedException("updates");
560
+ }
561
+
562
+ public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
563
+ throw new SQLFeatureNotSupportedException("updates");
564
+ }
565
+
566
+ public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
567
+ throw new SQLFeatureNotSupportedException("updates");
568
+ }
569
+
570
+ public void updateObject(int columnIndex, Object x) throws SQLException {
571
+ throw new SQLFeatureNotSupportedException("updates");
572
+ }
573
+
574
+ public void updateNull(String columnLabel) throws SQLException {
575
+ throw new SQLFeatureNotSupportedException("updates");
576
+ }
577
+
578
+ public void updateBoolean(String columnLabel, boolean x) throws SQLException {
579
+ throw new SQLFeatureNotSupportedException("updates");
580
+ }
581
+
582
+ public void updateByte(String columnLabel, byte x) throws SQLException {
583
+ throw new SQLFeatureNotSupportedException("updates");
584
+ }
585
+
586
+ public void updateShort(String columnLabel, short x) throws SQLException {
587
+ throw new SQLFeatureNotSupportedException("updates");
588
+ }
589
+
590
+ public void updateInt(String columnLabel, int x) throws SQLException {
591
+ throw new SQLFeatureNotSupportedException("updates");
592
+ }
593
+
594
+ public void updateLong(String columnLabel, long x) throws SQLException {
595
+ throw new SQLFeatureNotSupportedException("updates");
596
+ }
597
+
598
+ public void updateFloat(String columnLabel, float x) throws SQLException {
599
+ throw new SQLFeatureNotSupportedException("updates");
600
+ }
601
+
602
+ public void updateDouble(String columnLabel, double x) throws SQLException {
603
+ throw new SQLFeatureNotSupportedException("updates");
604
+ }
605
+
606
+ public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
607
+ throw new SQLFeatureNotSupportedException("updates");
608
+ }
609
+
610
+ public void updateString(String columnLabel, String x) throws SQLException {
611
+ throw new SQLFeatureNotSupportedException("updates");
612
+ }
613
+
614
+ public void updateBytes(String columnLabel, byte[] x) throws SQLException {
615
+ throw new SQLFeatureNotSupportedException("updates");
616
+ }
617
+
618
+ public void updateDate(String columnLabel, Date x) throws SQLException {
619
+ throw new SQLFeatureNotSupportedException("updates");
620
+ }
621
+
622
+ public void updateTime(String columnLabel, Time x) throws SQLException {
623
+ throw new SQLFeatureNotSupportedException("updates");
624
+ }
625
+
626
+ public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
627
+ throw new SQLFeatureNotSupportedException("updates");
628
+ }
629
+
630
+ public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
631
+ throw new SQLFeatureNotSupportedException("updates");
632
+ }
633
+
634
+ public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
635
+ throw new SQLFeatureNotSupportedException("updates");
636
+ }
637
+
638
+ public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
639
+ throw new SQLFeatureNotSupportedException("updates");
640
+ }
641
+
642
+ public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
643
+ throw new SQLFeatureNotSupportedException("updates");
644
+ }
645
+
646
+ public void updateObject(String columnLabel, Object x) throws SQLException {
647
+ throw new SQLFeatureNotSupportedException("updates");
648
+ }
649
+
650
+ public void updateRef(int columnIndex, Ref x) throws SQLException {
651
+ throw new SQLFeatureNotSupportedException("updates");
652
+ }
653
+
654
+ public void updateRef(String columnLabel, Ref x) throws SQLException {
655
+ throw new SQLFeatureNotSupportedException("updates");
656
+ }
657
+
658
+ public void updateBlob(int columnIndex, Blob x) throws SQLException {
659
+ throw new SQLFeatureNotSupportedException("updates");
660
+ }
661
+
662
+ public void updateBlob(String columnLabel, Blob x) throws SQLException {
663
+ throw new SQLFeatureNotSupportedException("updates");
664
+ }
665
+
666
+ public void updateClob(int columnIndex, Clob x) throws SQLException {
667
+ throw new SQLFeatureNotSupportedException("updates");
668
+ }
669
+
670
+ public void updateClob(String columnLabel, Clob x) throws SQLException {
671
+ throw new SQLFeatureNotSupportedException("updates");
672
+ }
673
+
674
+ public void updateArray(int columnIndex, Array x) throws SQLException {
675
+ throw new SQLFeatureNotSupportedException("updates");
676
+ }
677
+
678
+ public void updateArray(String columnLabel, Array x) throws SQLException {
679
+ throw new SQLFeatureNotSupportedException("updates");
680
+ }
681
+
682
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
683
+ throw new SQLFeatureNotSupportedException("updates");
684
+ }
685
+
686
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
687
+ throw new SQLFeatureNotSupportedException("updates");
688
+ }
689
+
690
+ public void updateNString(int columnIndex, String nString) throws SQLException {
691
+ throw new SQLFeatureNotSupportedException("updates");
692
+ }
693
+
694
+ public void updateNString(String columnLabel, String nString) throws SQLException {
695
+ throw new SQLFeatureNotSupportedException("updates");
696
+ }
697
+
698
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
699
+ throw new SQLFeatureNotSupportedException("updates");
700
+ }
701
+
702
+ public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
703
+ throw new SQLFeatureNotSupportedException("updates");
704
+ }
705
+
706
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
707
+ throw new SQLFeatureNotSupportedException("updates");
708
+ }
709
+
710
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
711
+ throw new SQLFeatureNotSupportedException("updates");
712
+ }
713
+
714
+ public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
715
+ throw new SQLFeatureNotSupportedException("updates");
716
+ }
717
+
718
+ public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
719
+ throw new SQLFeatureNotSupportedException("updates");
720
+ }
721
+
722
+ public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
723
+ throw new SQLFeatureNotSupportedException("updates");
724
+ }
725
+
726
+ public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
727
+ throw new SQLFeatureNotSupportedException("updates");
728
+ }
729
+
730
+ public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
731
+ throw new SQLFeatureNotSupportedException("updates");
732
+ }
733
+
734
+ public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
735
+ throw new SQLFeatureNotSupportedException("updates");
736
+ }
737
+
738
+ public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
739
+ throw new SQLFeatureNotSupportedException("updates");
740
+ }
741
+
742
+ public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
743
+ throw new SQLFeatureNotSupportedException("updates");
744
+ }
745
+
746
+ public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
747
+ throw new SQLFeatureNotSupportedException("updates");
748
+ }
749
+
750
+ public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
751
+ throw new SQLFeatureNotSupportedException("updates");
752
+ }
753
+
754
+ public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
755
+ throw new SQLFeatureNotSupportedException("updates");
756
+ }
757
+
758
+ public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
759
+ throw new SQLFeatureNotSupportedException("updates");
760
+ }
761
+
762
+ public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
763
+ throw new SQLFeatureNotSupportedException("updates");
764
+ }
765
+
766
+ public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
767
+ throw new SQLFeatureNotSupportedException("updates");
768
+ }
769
+
770
+ public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
771
+ throw new SQLFeatureNotSupportedException("updates");
772
+ }
773
+
774
+ public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
775
+ throw new SQLFeatureNotSupportedException("updates");
776
+ }
777
+
778
+ public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
779
+ throw new SQLFeatureNotSupportedException("updates");
780
+ }
781
+
782
+ public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
783
+ throw new SQLFeatureNotSupportedException("updates");
784
+ }
785
+
786
+ public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
787
+ throw new SQLFeatureNotSupportedException("updates");
788
+ }
789
+
790
+ public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
791
+ throw new SQLFeatureNotSupportedException("updates");
792
+ }
793
+
794
+ public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
795
+ throw new SQLFeatureNotSupportedException("updates");
796
+ }
797
+
798
+ public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
799
+ throw new SQLFeatureNotSupportedException("updates");
800
+ }
801
+
802
+ public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
803
+ throw new SQLFeatureNotSupportedException("updates");
804
+ }
805
+
806
+ public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
807
+ throw new SQLFeatureNotSupportedException("updates");
808
+ }
809
+
810
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
811
+ throw new SQLFeatureNotSupportedException("updates");
812
+ }
813
+
814
+ public void updateClob(String columnLabel, Reader reader) throws SQLException {
815
+ throw new SQLFeatureNotSupportedException("updates");
816
+ }
817
+
818
+ public void updateNClob(int columnIndex, Reader reader) throws SQLException {
819
+ throw new SQLFeatureNotSupportedException("updates");
820
+ }
821
+
822
+ public void updateNClob(String columnLabel, Reader reader) throws SQLException {
823
+ throw new SQLFeatureNotSupportedException("updates");
824
+ }
825
+
826
+ }