// Set SQL mode to standard ANSI and TRADITIONAL.
try {
this.getConnection().createStatement().executeUpdate("SET SQL_MODE = 'ANSI,TRADITIONAL'");
+/* Disabled to prevent an infinite loop.
this.logStatement("### SET SQL_MODE = 'ANSI,TRADITIONAL' ###");
+*/
}
catch (SQLException exception) {
throw new MDatabaseConnectionFailureException("Could not set SQL mode to ANSI and TRADITIONAL.", exception);
/* Statements. */
public MSqlStatementResults executePreparedStatement(String statement) throws MDatabaseConnectionFailureException, MSqlStatementException {
- return this.executePreparedStatement(statement, new LinkedList<Object>(), this.getLocalTypesMode());
+ return this.executePreparedStatement(statement, new LinkedList<Object>());
}
public MSqlStatementResults executePreparedStatement(String statement, LinkedList<Object> parameters) throws MDatabaseConnectionFailureException, MSqlStatementException {
}
public MSqlStatementResults executePreparedStatement(String statement, LinkedList<Object> parameters, boolean localTypesMode) throws MDatabaseConnectionFailureException, MSqlStatementException {
+ return this.executePreparedStatement(statement, parameters, this.getLocalTypesMode(), true);
+ };
+
+ public MSqlStatementResults executePreparedStatement(String statement, LinkedList<Object> parameters, boolean localTypesMode, boolean loggableStatement) throws MDatabaseConnectionFailureException, MSqlStatementException {
if (MText.isBlank(statement)) {
throw new IllegalArgumentException("Invalid 'statement': null or empty.");
}
// Execute the statement and parse the results.
preparedStatement.execute();
results = new MSqlStatementResults(preparedStatement, localTypesMode);
- this.logStatement(preparedStatement.toString());
+ if (loggableStatement) {
+ this.logStatement(preparedStatement.toString());
+ }
}
catch (MDatabaseConnectionFailureException exception) {
if (MDatabaseConnection.TransactionStatus.SUCCESSFUL == this.getTransactionStatus()) {
/* Statements. */
- protected MSqlStatementResults insertRecord(LinkedHashMap<String, Object> map) throws MDatabaseConnectionFailureException, MSqlStatementException {
+ protected MSqlStatementResults insertRecord(LinkedHashMap<String, Object> map, boolean loggableStatement) throws MDatabaseConnectionFailureException, MSqlStatementException {
if (null == map) {
throw new IllegalArgumentException("Invalid 'map': null.");
}
return this.getDatabaseConnection().executePreparedStatement(" INSERT INTO \"" + this.getTable() + "\""
+ " (" + fields + ")"
+ " VALUES (" + s + ")",
- p);
+ p, true, loggableStatement);
}
- protected MSqlStatementResults updateRecord(LinkedHashMap<String, Object> map, Object id) throws MDatabaseConnectionFailureException, MSqlStatementException {
+ protected MSqlStatementResults updateRecord(LinkedHashMap<String, Object> map, Object id, boolean loggableStatement) throws MDatabaseConnectionFailureException, MSqlStatementException {
if (null == map) {
throw new IllegalArgumentException("Invalid 'map': null.");
}
return this.getDatabaseConnection().executePreparedStatement(" UPDATE \"" + this.getTable() + "\""
+ " SET " + s
+ " WHERE (\"" + this.getTable() + "\".\"" + this.getPrimaryKey() + "\" = ?)",
- p);
+ p, true, loggableStatement);
}
public MSqlStatementResults setRecord(LinkedHashMap<String, Object> map, Object id) throws MDatabaseConnectionFailureException, MSqlStatementException {
+ return this.setRecord(map, id, true);
+ }
+
+ public MSqlStatementResults setRecord(LinkedHashMap<String, Object> map, Object id, boolean loggableStatement) throws MDatabaseConnectionFailureException, MSqlStatementException {
if (null == id) {
- return this.insertRecord(map);
+ return this.insertRecord(map, loggableStatement);
}
else {
- return this.updateRecord(map, id);
+ return this.updateRecord(map, id, loggableStatement);
}
}
//
LinkedHashMap<String, Object> p = new LinkedHashMap<String, Object>();
p.put(this.getLogDatabaseField(), timestamp + separator + message);
- (new MSqlTable(databaseConnection, this.getLogDatabaseTable(), this.getLogDatabaseTablePrimaryKey())).setRecord(p, null);
+ (new MSqlTable(databaseConnection, this.getLogDatabaseTable(), this.getLogDatabaseTablePrimaryKey())).setRecord(p, null, false);
//
this.getDatabaseConnectionPool().pushDatabaseConnection(databaseConnection);
}