@@ -71,117 +71,74 @@ public boolean getBoolean(String name) throws SQLException {
71
71
return this .getBoolean (this .findColumn (name ));
72
72
}
73
73
74
- @ Override
75
- public int getInt (String name ) throws SQLException {
76
- return this .getInt (this .findColumn (name ));
77
- }
78
-
79
- @ Override
80
- public URL getURL (String name ) throws SQLException {
81
- return this .getURL (this .findColumn (name ));
82
- }
83
-
84
74
@ Override
85
75
public byte getByte (String name ) throws SQLException {
86
76
return this .getByte (this .findColumn (name ));
87
77
}
88
78
89
79
@ Override
90
- public byte [] getBytes (String name ) throws SQLException {
91
- return this .getBytes (this .findColumn (name ));
80
+ public short getShort (String name ) throws SQLException {
81
+ return this .getShort (this .findColumn (name ));
92
82
}
93
83
94
84
@ Override
95
- public Date getDate (String name ) throws SQLException {
96
- return this .getDate (this .findColumn (name ));
85
+ public int getInt (String name ) throws SQLException {
86
+ return this .getInt (this .findColumn (name ));
97
87
}
98
88
99
89
@ Override
100
90
public long getLong (String name ) throws SQLException {
101
91
return this .getLong (this .findColumn (name ));
102
92
}
103
93
104
- @ Override
105
- public Array getArray (String name ) throws SQLException {
106
- return this .getArray (this .findColumn (name ));
107
- }
108
-
109
94
@ Override
110
95
public float getFloat (String name ) throws SQLException {
111
96
return this .getFloat (this .findColumn (name ));
112
97
}
113
98
114
- @ Override
115
- public short getShort (String name ) throws SQLException {
116
- return this .getShort (this .findColumn (name ));
117
- }
118
-
119
99
@ Override
120
100
public double getDouble (String name ) throws SQLException {
121
101
return this .getDouble (this .findColumn (name ));
122
102
}
123
103
124
- @ Override
125
- public String getString (String name ) throws SQLException {
126
- return this .getString (this .findColumn (name ));
127
- }
128
-
129
- @ Override
130
- public Object getObject (String name ) throws SQLException {
131
- return this .getObject (this .findColumn (name ));
132
- }
133
-
134
104
@ Override
135
105
public Timestamp getTimestamp (String name ) throws SQLException {
136
106
return this .getTimestamp (this .findColumn (name ));
137
107
}
138
108
139
109
@ Override
140
- public BigDecimal getBigDecimal (String name ) throws SQLException {
141
- return this .getBigDecimal (this .findColumn (name ));
142
- }
143
-
144
- @ Override
145
- public boolean isBeforeFirst () throws SQLException {
146
- return currentRowNum == -1 ;
147
- }
148
-
149
- @ Override
150
- public boolean isAfterLast () throws SQLException {
151
- return isAfterLast ;
152
- }
153
-
154
- @ Override
155
- public boolean isFirst () throws SQLException {
156
- return isFirst ;
110
+ public Date getDate (String name ) throws SQLException {
111
+ return this .getDate (this .findColumn (name ));
157
112
}
158
113
159
114
@ Override
160
- public boolean first ( ) throws SQLException {
161
- throw new SQLException ( "TYPE_FORWARD_ONLY" );
115
+ public BigDecimal getBigDecimal ( String name ) throws SQLException {
116
+ return this . getBigDecimal ( this . findColumn ( name ) );
162
117
}
163
118
164
119
@ Override
165
- public boolean last ( ) throws SQLException {
166
- throw new SQLException ( "TYPE_FORWARD_ONLY" );
120
+ public String getString ( String name ) throws SQLException {
121
+ return this . getString ( this . findColumn ( name ) );
167
122
}
168
123
169
124
@ Override
170
- public void setFetchDirection (int direction ) throws SQLException {
125
+ public byte [] getBytes (String name ) throws SQLException {
126
+ return this .getBytes (this .findColumn (name ));
171
127
}
172
128
173
129
@ Override
174
- public int getFetchDirection ( ) throws SQLException {
175
- return ResultSet . FETCH_FORWARD ;
130
+ public URL getURL ( String name ) throws SQLException {
131
+ return this . getURL ( this . findColumn ( name )) ;
176
132
}
177
133
178
134
@ Override
179
- public void setFetchSize (int rows ) throws SQLException {
135
+ public Array getArray (String name ) throws SQLException {
136
+ return this .getArray (this .findColumn (name ));
180
137
}
181
138
182
139
@ Override
183
- public int getFetchSize ( ) throws SQLException {
184
- return Integer . MAX_VALUE ;
140
+ public Object getObject ( String name ) throws SQLException {
141
+ return this . getObject ( this . findColumn ( name )) ;
185
142
}
186
143
187
144
@ Override
@@ -194,36 +151,30 @@ public boolean getBoolean(int index) throws SQLException {
194
151
}
195
152
196
153
@ Override
197
- public int getInt (int index ) throws SQLException {
154
+ public byte getByte (int index ) throws SQLException {
198
155
Object data = getObject (index );
199
156
if (data == null ) {
200
157
return 0 ;
201
158
}
202
- return ((Number ) data ).intValue ();
203
- }
204
-
205
- @ Override
206
- public URL getURL (int index ) throws SQLException {
207
- try {
208
- return new URL (this .getString (index ));
209
- } catch (MalformedURLException ex ) {
210
- throw new SQLException (ex .getMessage (), ex );
211
- }
159
+ return ((Number ) data ).byteValue ();
212
160
}
213
161
214
162
@ Override
215
- public byte getByte (int index ) throws SQLException {
163
+ public short getShort (int index ) throws SQLException {
216
164
Object data = getObject (index );
217
165
if (data == null ) {
218
166
return 0 ;
219
167
}
220
- return ((Number ) data ).byteValue ();
168
+ return ((Number ) data ).shortValue ();
221
169
}
222
170
223
171
@ Override
224
- public Date getDate (int index ) throws SQLException {
172
+ public int getInt (int index ) throws SQLException {
225
173
Object data = getObject (index );
226
- return (Date ) data ;
174
+ if (data == null ) {
175
+ return 0 ;
176
+ }
177
+ return ((Number ) data ).intValue ();
227
178
}
228
179
229
180
@ Override
@@ -235,12 +186,6 @@ public long getLong(int index) throws SQLException {
235
186
return ((Number ) data ).longValue ();
236
187
}
237
188
238
- @ Override
239
- public Array getArray (int index ) throws SQLException {
240
- Object data = getObject (index );
241
- return (Array ) data ;
242
- }
243
-
244
189
@ Override
245
190
public float getFloat (int index ) throws SQLException {
246
191
Object data = getObject (index );
@@ -251,21 +196,30 @@ public float getFloat(int index) throws SQLException {
251
196
}
252
197
253
198
@ Override
254
- public short getShort (int index ) throws SQLException {
199
+ public double getDouble (int index ) throws SQLException {
255
200
Object data = getObject (index );
256
201
if (data == null ) {
257
202
return 0 ;
258
203
}
259
- return ((Number ) data ).shortValue ();
204
+ return ((Number ) data ).doubleValue ();
260
205
}
261
206
262
207
@ Override
263
- public double getDouble (int index ) throws SQLException {
208
+ public Timestamp getTimestamp (int index ) throws SQLException {
264
209
Object data = getObject (index );
265
- if (data == null ) {
266
- return 0 ;
267
- }
268
- return ((Number ) data ).doubleValue ();
210
+ return (Timestamp ) data ;
211
+ }
212
+
213
+ @ Override
214
+ public Date getDate (int index ) throws SQLException {
215
+ Object data = getObject (index );
216
+ return (Date ) data ;
217
+ }
218
+
219
+ @ Override
220
+ public BigDecimal getBigDecimal (int index ) throws SQLException {
221
+ Object data = getObject (index );
222
+ return new BigDecimal (data .toString ());
269
223
}
270
224
271
225
@ Override
@@ -284,6 +238,21 @@ public byte[] getBytes(int index) throws SQLException {
284
238
return data .getBytes (cfg .charset ());
285
239
}
286
240
241
+ @ Override
242
+ public URL getURL (int index ) throws SQLException {
243
+ try {
244
+ return new URL (this .getString (index ));
245
+ } catch (MalformedURLException ex ) {
246
+ throw new SQLException (ex .getMessage (), ex );
247
+ }
248
+ }
249
+
250
+ @ Override
251
+ public Array getArray (int index ) throws SQLException {
252
+ Object data = getObject (index );
253
+ return (Array ) data ;
254
+ }
255
+
287
256
@ Override
288
257
public Object getObject (int index ) throws SQLException {
289
258
LOG .trace ("get object at row: {}, column: {} from block with column count: {}, row count: {}" ,
@@ -295,31 +264,56 @@ public Object getObject(int index) throws SQLException {
295
264
}
296
265
297
266
@ Override
298
- public Timestamp getTimestamp (int index ) throws SQLException {
299
- Object data = getObject (index );
300
- return (Timestamp ) data ;
267
+ public boolean first () throws SQLException {
268
+ throw new SQLException ("TYPE_FORWARD_ONLY" );
301
269
}
302
270
303
271
@ Override
304
- public BigDecimal getBigDecimal (int index ) throws SQLException {
305
- Object data = getObject (index );
306
- return new BigDecimal (data .toString ());
272
+ public boolean last () throws SQLException {
273
+ throw new SQLException ("TYPE_FORWARD_ONLY" );
274
+ }
275
+
276
+ @ Override
277
+ public boolean isBeforeFirst () throws SQLException {
278
+ return currentRowNum == -1 ;
279
+ }
280
+
281
+ @ Override
282
+ public boolean isFirst () throws SQLException {
283
+ return isFirst ;
284
+ }
285
+
286
+ @ Override
287
+ public boolean isAfterLast () throws SQLException {
288
+ return isAfterLast ;
289
+ }
290
+
291
+ @ Override
292
+ public void setFetchDirection (int direction ) throws SQLException {
293
+ }
294
+
295
+ @ Override
296
+ public int getFetchDirection () throws SQLException {
297
+ return ResultSet .FETCH_FORWARD ;
307
298
}
308
299
309
- /*==================================================================*/
300
+ @ Override
301
+ public void setFetchSize (int rows ) throws SQLException {
302
+ }
303
+
304
+ @ Override
305
+ public int getFetchSize () throws SQLException {
306
+ return Integer .MAX_VALUE ;
307
+ }
310
308
311
309
@ Override
312
310
public int getType () throws SQLException {
313
311
return ResultSet .TYPE_FORWARD_ONLY ;
314
312
}
315
313
316
314
@ Override
317
- public void close () throws SQLException {
318
- // TODO check if query responses are completed
319
- // 1. if completed, just set isClosed = true
320
- // 2. if not, cancel query and consume the rest responses
321
- LOG .debug ("close ResultSet" );
322
- this .isClosed = true ;
315
+ public ResultSetMetaData getMetaData () throws SQLException {
316
+ return new ClickHouseResultSetMetaData (header , db , table );
323
317
}
324
318
325
319
@ Override
@@ -335,11 +329,6 @@ public int getHoldability() throws SQLException {
335
329
return ResultSet .CLOSE_CURSORS_AT_COMMIT ;
336
330
}
337
331
338
- @ Override
339
- public boolean isClosed () throws SQLException {
340
- return this .isClosed ;
341
- }
342
-
343
332
@ Override
344
333
public Statement getStatement () throws SQLException {
345
334
return statement ;
@@ -351,11 +340,6 @@ public int findColumn(String name) throws SQLException {
351
340
return header .getPositionByName (name );
352
341
}
353
342
354
- @ Override
355
- public ResultSetMetaData getMetaData () throws SQLException {
356
- return new ClickHouseResultSetMetaData (header , db , table );
357
- }
358
-
359
343
@ Override
360
344
public boolean next () throws SQLException {
361
345
boolean isBeforeFirst = isBeforeFirst ();
@@ -370,6 +354,20 @@ public boolean next() throws SQLException {
370
354
return hasNext ;
371
355
}
372
356
357
+ @ Override
358
+ public void close () throws SQLException {
359
+ // TODO check if query responses are completed
360
+ // 1. if completed, just set isClosed = true
361
+ // 2. if not, cancel query and consume the rest responses
362
+ LOG .debug ("close ResultSet" );
363
+ this .isClosed = true ;
364
+ }
365
+
366
+ @ Override
367
+ public boolean isClosed () throws SQLException {
368
+ return this .isClosed ;
369
+ }
370
+
373
371
@ Override
374
372
public Logger logger () {
375
373
return ClickHouseResultSet .LOG ;
0 commit comments