From: Marco Zanon Date: Wed, 28 Aug 2024 16:53:32 +0000 (+0000) Subject: Fixed an exception when setting the SQL mode on non-MySQL-like databases. X-Git-Tag: SVN-to-Git~1 X-Git-Url: https://gitweb.marcozanon.com/?a=commitdiff_plain;h=fe7a932896f199a7990aacb2e60e4f1d4291f5a8;p=Macaco Fixed an exception when setting the SQL mode on non-MySQL-like databases. --- diff --git a/10.x/CHANGELOG b/10.x/CHANGELOG index 78d70a4..41c4fe1 100644 --- a/10.x/CHANGELOG +++ b/10.x/CHANGELOG @@ -2,6 +2,11 @@ Macaco Copyright (c) 2009-2024 Marco Zanon . See LICENSE for details. +------------------- +10.1.1 (2024-08-28) +------------------- +* Fixed an exception when setting the SQL mode on non-MySQL-like databases. + ------------------- 10.1.0 (2024-07-28) ------------------- diff --git a/10.x/src/main/java/com/marcozanon/macaco/databases/MDatabaseConnection.java b/10.x/src/main/java/com/marcozanon/macaco/databases/MDatabaseConnection.java index a3e8f41..fc611e2 100644 --- a/10.x/src/main/java/com/marcozanon/macaco/databases/MDatabaseConnection.java +++ b/10.x/src/main/java/com/marcozanon/macaco/databases/MDatabaseConnection.java @@ -84,15 +84,17 @@ public class MDatabaseConnection extends MObject { catch (SQLException exception) { throw new MDatabaseConnectionFailureException("Could not get database connection.", exception); } - // Set SQL mode to standard ANSI and TRADITIONAL. - try { - this.getConnection().createStatement().executeUpdate("SET SQL_MODE = 'ANSI,TRADITIONAL'"); + // Set SQL mode to standard ANSI and TRADITIONAL (MySQL / MariaDB databases only). + if (this.getDriver().toLowerCase().matches(".*(mysql|mariadb){1}.*")) { + try { + this.getConnection().createStatement().executeUpdate("SET SQL_MODE = 'ANSI,TRADITIONAL'"); /* Disabled to prevent an infinite loop. - this.logStatement("### SET SQL_MODE = 'ANSI,TRADITIONAL' ###"); + this.logStatement("### SET SQL_MODE = 'ANSI,TRADITIONAL' ###"); */ - } - catch (SQLException exception) { - throw new MDatabaseConnectionFailureException("Could not set SQL mode to ANSI and TRADITIONAL.", exception); + } + catch (SQLException exception) { + throw new MDatabaseConnectionFailureException("Could not set SQL mode to ANSI and TRADITIONAL.", exception); + } } }