From e10c4a3d6723d69febb4f97deb35f1b58233e5c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Michael?= Date: Sat, 22 May 2021 06:21:11 +0200 Subject: [PATCH] ClientPreparedStmt: Leave Calendar untouched --- .../java/com/mysql/cj/ClientPreparedQueryBindings.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java b/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java index 713ecb90a..c46a8cdfc 100644 --- a/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java +++ b/src/main/core-impl/java/com/mysql/cj/ClientPreparedQueryBindings.java @@ -414,6 +414,7 @@ public void setDate(int parameterIndex, Date x, Calendar cal) { if (x == null) { setNull(parameterIndex); } else if (cal != null) { + cal = (Calendar) cal.clone(); setValue(parameterIndex, TimeUtil.getSimpleDateFormat("''yyyy-MM-dd''", cal).format(x), MysqlType.DATE); } else { this.ddf = TimeUtil.getSimpleDateFormat(this.ddf, "''yyyy-MM-dd''", this.session.getServerSession().getDefaultTimeZone()); @@ -879,6 +880,7 @@ public void setTime(int parameterIndex, Time x, Calendar cal) { && this.sendFractionalSecondsForTime.getValue() && TimeUtil.hasFractionalSeconds(x) ? "''HH:mm:ss.SSS''" : "''HH:mm:ss''"; if (cal != null) { + cal = (Calendar) cal.clone(); setValue(parameterIndex, TimeUtil.getSimpleDateFormat(formatStr, cal).format(x), MysqlType.TIME); } else { this.tdf = TimeUtil.getSimpleDateFormat(this.tdf, formatStr, this.session.getServerSession().getDefaultTimeZone()); @@ -902,6 +904,7 @@ public void bindTimestamp(int parameterIndex, Timestamp x, Calendar targetCalend StringBuffer buf = new StringBuffer(); if (targetCalendar != null) { + targetCalendar = (Calendar) targetCalendar.clone(); buf.append(TimeUtil.getSimpleDateFormat("''yyyy-MM-dd HH:mm:ss", targetCalendar).format(x)); } else { this.tsdf = TimeUtil.getSimpleDateFormat(this.tsdf, "''yyyy-MM-dd HH:mm:ss",