@@ -189,7 +189,7 @@ public Time getTime(int columnIndex) throws SQLException {
189189
190190 @ Override
191191 public Timestamp getTimestamp (int columnIndex ) throws SQLException {
192- return getTimestamp (columnIndexToName ( columnIndex ) );
192+ return getTimestamp (columnIndex , null );
193193 }
194194
195195 @ Override
@@ -404,19 +404,7 @@ public Time getTime(String columnLabel) throws SQLException {
404404
405405 @ Override
406406 public Timestamp getTimestamp (String columnLabel ) throws SQLException {
407- checkClosed ();
408- try {
409- LocalDateTime localDateTime = reader .getLocalDateTime (columnLabel );
410- if (localDateTime == null ) {
411- wasNull = true ;
412- return null ;
413- }
414-
415- wasNull = false ;
416- return Timestamp .valueOf (localDateTime );
417- } catch (Exception e ) {
418- throw ExceptionUtils .toSqlState (String .format ("SQL: [%s]; Method: getTimestamp(%s)" , parentStatement .getLastSql (), columnLabel ), e );
419- }
407+ return getTimestamp (columnLabel , null );
420408 }
421409
422410 @ Override
@@ -1104,13 +1092,45 @@ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
11041092
11051093 @ Override
11061094 public Timestamp getTimestamp (int columnIndex , Calendar cal ) throws SQLException {
1107- return getTimestamp (columnIndexToName (columnIndex ), cal );
1095+ checkClosed ();
1096+ try {
1097+ LocalDateTime localDateTime = reader .getLocalDateTime (columnIndex );
1098+ if (localDateTime == null ) {
1099+ wasNull = true ;
1100+ return null ;
1101+ }
1102+ Calendar c = (Calendar ) (cal != null ? cal : defaultCalendar ).clone ();
1103+ c .set (localDateTime .getYear (), localDateTime .getMonthValue () - 1 , localDateTime .getDayOfMonth (), localDateTime .getHour (), localDateTime .getMinute (),
1104+ localDateTime .getSecond ());
1105+ Timestamp timestamp = new Timestamp (c .getTimeInMillis ());
1106+ timestamp .setNanos (localDateTime .getNano ());
1107+ wasNull = false ;
1108+ return timestamp ;
1109+ } catch (Exception e ) {
1110+ throw ExceptionUtils .toSqlState (String .format ("SQL: [%s]; Method: getTimestamp(%s)" , parentStatement .getLastSql (), columnIndex ), e );
1111+ }
11081112 }
11091113
11101114 @ Override
11111115 public Timestamp getTimestamp (String columnLabel , Calendar cal ) throws SQLException {
11121116 checkClosed ();
1113- return getTimestamp (columnLabel );
1117+ try {
1118+ LocalDateTime localDateTime = reader .getLocalDateTime (columnLabel );
1119+ if (localDateTime == null ) {
1120+ wasNull = true ;
1121+ return null ;
1122+ }
1123+ Calendar c = (Calendar ) (cal != null ? cal : defaultCalendar ).clone ();
1124+ c .set (localDateTime .getYear (), localDateTime .getMonthValue () - 1 , localDateTime .getDayOfMonth (), localDateTime .getHour (), localDateTime .getMinute (),
1125+ localDateTime .getSecond ());
1126+ Timestamp timestamp = new Timestamp (c .getTimeInMillis ());
1127+ timestamp .setNanos (localDateTime .getNano ());
1128+ wasNull = false ;
1129+ return timestamp ;
1130+ } catch (Exception e ) {
1131+ throw ExceptionUtils .toSqlState (String .format ("SQL: [%s]; Method: getTimestamp(%s)" , parentStatement .getLastSql (), columnLabel ), e );
1132+ }
1133+
11141134 }
11151135
11161136 @ Override
0 commit comments