88import java .io .InputStream ;
99import java .io .Reader ;
1010import java .math .BigDecimal ;
11- import java .math .BigInteger ;
1211import java .net .URL ;
1312import java .sql .Array ;
1413import java .sql .Blob ;
2625import java .sql .Timestamp ;
2726import java .util .Calendar ;
2827import java .util .Map ;
29- import java .util .OptionalDouble ;
3028import java .util .OptionalLong ;
3129import lombok .AllArgsConstructor ;
3230import lombok .val ;
@@ -86,7 +84,7 @@ public SQLWarning getWarnings() throws SQLException {
8684
8785 @ Override
8886 public void clearWarnings () throws SQLException {
89- // No-op, since we don't support warnings
87+ throw new SQLFeatureNotSupportedException ( "clearWarnings is not supported" );
9088 }
9189
9290 @ Override
@@ -178,35 +176,6 @@ public long getLong(int columnIndex) throws SQLException {
178176 wasNull = !v .isPresent ();
179177 return v .orElse (0L );
180178 }
181- case FLOAT :
182- case DOUBLE : {
183- OptionalDouble d = getAccessor (columnIndex ).getAnyFloatingPoint (getSubclass ());
184- wasNull = !d .isPresent ();
185- double dv = d .orElse (0.0 );
186- // The way this condition is written, it will never be true for NaN or Infinity.
187- // This is good because we want to throw an exception for those values.
188- if (dv >= LONG_MIN_DOUBLE && dv <= LONG_MAX_DOUBLE ) {
189- return (long ) dv ;
190- }
191- throw new SQLException ("Column " + getMetaData ().getColumnName (columnIndex )
192- + " is out of range for an integer-like type" );
193- }
194- case NUMERIC : {
195- BigDecimal v = getBigDecimal (columnIndex );
196- wasNull = v == null ;
197- if (wasNull ) {
198- return 0L ;
199- } else {
200- BigInteger i = v .toBigInteger ();
201- int gt = i .compareTo (BigInteger .valueOf (Long .MAX_VALUE ));
202- int lt = i .compareTo (BigInteger .valueOf (Long .MIN_VALUE ));
203- if (gt > 0 || lt < 0 ) {
204- throw new SQLException ("Column " + getMetaData ().getColumnName (columnIndex )
205- + " is out of range for an integer-like type" );
206- }
207- return v .longValue ();
208- }
209- }
210179 default :
211180 throw new SQLException ("Unsupported column type for integer-like types: "
212181 + metadata .getColumn (columnIndex ).getType ().toString ());
@@ -236,17 +205,6 @@ public double getDouble(int columnIndex) throws SQLException {
236205 wasNull = !v .isPresent ();
237206 return v .orElse (0L );
238207 }
239- case FLOAT :
240- case DOUBLE : {
241- val v = getAccessor (columnIndex ).getAnyFloatingPoint (getSubclass ());
242- wasNull = !v .isPresent ();
243- return v .orElse (0.0 );
244- }
245- case NUMERIC : {
246- BigDecimal v = getBigDecimal (columnIndex );
247- wasNull = v == null ;
248- return v == null ? 0.0 : v .doubleValue ();
249- }
250208 default :
251209 throw new SQLException ("Unsupported column type for floating-point types: "
252210 + metadata .getColumn (columnIndex ).getType ().toString ());
@@ -265,11 +223,6 @@ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
265223 }
266224 // TODO: apparently, PostgreSQL does not support float/decimal conversion. Double-check this with test
267225 // cases.
268- case NUMERIC : {
269- val v = getAccessor (columnIndex ).getBigDecimal (getSubclass ());
270- wasNull = v == null ;
271- return v ;
272- }
273226 default :
274227 throw new SQLException ("Unsupported column type for numeric types: "
275228 + metadata .getColumn (columnIndex ).getType ().toString ());
@@ -278,22 +231,14 @@ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
278231
279232 @ Override
280233 public BigDecimal getBigDecimal (int columnIndex , int scale ) throws SQLException {
281- val v = getBigDecimal (columnIndex );
282- if (wasNull ) {
283- return null ;
284- }
285- try {
286- return v .setScale (scale );
287- } catch (ArithmeticException e ) {
288- throw new SQLException ("Bad value for type BigDecimal: " + v );
289- }
234+ // TODO implement this
235+ throw new UnsupportedOperationException ("Unimplemented method 'getBigDecimal'" );
290236 }
291237
292238 @ Override
293239 public byte [] getBytes (int columnIndex ) throws SQLException {
294- val v = getAccessor (columnIndex ).getBytes (getSubclass ());
295- wasNull = v == null ;
296- return v ;
240+ // TODO implement this
241+ throw new UnsupportedOperationException ("Unimplemented method 'getBytes'" );
297242 }
298243
299244 @ Override
@@ -331,72 +276,23 @@ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException
331276
332277 @ Override
333278 public Array getArray (int columnIndex ) throws SQLException {
334- val v = getAccessor (columnIndex ).getArray (getSubclass ());
335- wasNull = v == null ;
336- return v ;
279+ // TODO implement this
280+ throw new UnsupportedOperationException ("Unimplemented method 'getArray'" );
337281 }
338282
339283 @ Override
340284 public Object getObject (int columnIndex ) throws SQLException {
341285 switch (metadata .getColumn (columnIndex ).getType ().getType ()) {
342- case BOOLEAN : {
343- val v = getBoolean (columnIndex );
344- if (wasNull ) {
345- return null ;
346- }
347- return v ;
348- }
349- case SMALLINT : {
350- val v = getShort (columnIndex );
351- if (wasNull ) {
352- return null ;
353- }
354- return v ;
355- }
356286 case INTEGER : {
357287 val v = getInt (columnIndex );
358288 if (wasNull ) {
359289 return null ;
360290 }
361291 return v ;
362292 }
363- case BIGINT : {
364- val v = getLong (columnIndex );
365- if (wasNull ) {
366- return null ;
367- }
368- return v ;
369- }
370- case NUMERIC :
371- return getBigDecimal (columnIndex );
372- case FLOAT : {
373- val v = getFloat (columnIndex );
374- if (wasNull ) {
375- return null ;
376- }
377- return v ;
378- }
379- case DOUBLE : {
380- val v = getDouble (columnIndex );
381- if (wasNull ) {
382- return null ;
383- }
384- return v ;
385- }
386293 case CHAR :
387294 case VARCHAR :
388295 return getString (columnIndex );
389- case BINARY :
390- return getBytes (columnIndex );
391- case DATE :
392- return getDate (columnIndex );
393- case TIME :
394- return getTime (columnIndex );
395- case TIMESTAMP :
396- case TIMESTAMP_WITH_TIMEZONE :
397- return getTimestamp (columnIndex );
398- case ARRAY :
399- return getArray (columnIndex );
400296 }
401297 throw new SQLException ("Unsupported column type in `getObject`: "
402298 + metadata .getColumn (columnIndex ).getType ().toString ());
0 commit comments