diff --git a/.travis.yml b/.travis.yml
index fd38483a8..3e10275cb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
os: linux
-dist: bionic
+dist: jammy
language: java
services:
- docker
@@ -47,19 +47,30 @@ jobs:
allow_failures:
- env: srv=build
- env: srv=xpand TEST_DB_OTHER="&initSql=SET NAMES UTF8"
+ - env: srv=mariadb-es local=1
+ - env: srv=skysql
+ - env: srv=skysql-ha
include:
- stage: Minimal
env: srv=mariadb v=10.6 packet=8
name: "CS 10.6"
- - env: srv=mariadb-es v=10.6
- name: "ES 10.6"
+ - env: srv=mariadb-es
+ name: "ES latest"
if: type = push AND fork = false
- stage: Enterprise
env: srv=mariadb-es v=10.4
+ dist: bionic
name: "ES 10.4"
- env: srv=mariadb-es v=10.5
+ dist: bionic
name: "ES 10.5"
+ - env: srv=mariadb-es v=10.6
+ name: "ES 10.6"
+ if: type = push AND fork = false
+ - env: srv=mariadb-es-test v=23.06
+ name: "ES 23.06"
+ if: type = push AND fork = false
- env: srv=maxscale
name: "Maxscale"
- env: srv=xpand TEST_DB_OTHER="&initSql=SET NAMES UTF8"
@@ -74,18 +85,22 @@ jobs:
os: windows
language: shell
name: "CS 10.6 - Windows"
- - env: srv=mariadb v=10.3 local=1
- name: "CS 10.3"
- env: srv=mariadb v=10.4 local=1
+ dist: bionic
name: "CS 10.4"
- env: srv=mariadb v=10.5 local=1
+ dist: bionic
name: "CS 10.5"
- - env: srv=mariadb v=10.7 local=1
- name: "CS 10.7"
- - env: srv=mariadb v=10.8 local=1
- name: "CS 10.8"
- env: srv=mariadb v=10.9 local=1
name: "CS 10.9"
+ - env: srv=mariadb v=10.10 local=1
+ name: "CS 10.10"
+ - env: srv=mariadb v=10.11 local=1
+ name: "CS 10.11"
+ - env: srv=mariadb v=11.0 local=1
+ name: "CS 11.0"
+ - env: srv=mariadb v=11.1-rc local=1
+ name: "CS 11.1"
- env: srv=mariadb v=10.6 packet=40
jdk: openjdk17
name: "CS 10.6 - openjdk 17"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 92cb3d8a3..4938f7618 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,36 @@
# Change Log
+
+## [3.2.0](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.2.0) (Aug 2023)
+[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.1.4...3.2.0)
+
+##### Notable Changes
+* CONJ-920 Java batched statements with optimistic locking failing. the option `useBulkStmts` is now disable by default, a new option `useBulkStmtsForInserts` is enable by default, permetting using bulk for INSERT commands only. This permits optimistic behavior working by default.
+* CONJ-1084 When using maxscale 23.08.0+, and a maxscale node fails, connector will now priorize reconnection to the maxscale node having less connection, to ensure repartition after failover
+* CONJ-1088 Implement `databaseTerm` option for mysql compatibility
+* CONJ-1096 adding option `useLocalSessionState` to permit avoiding queries when application only use JDBC methods.
+
+##### Bugs Fixed
+* CONJ-1075 LOAD DATA INFILE is broken on windows
+* CONJ-1079 getGeneratedKeys after batch will not return all generated id's if first batch command return no generated id.
+* CONJ-1080 maridb Java connector sslMode=verify-ca complaining unable to find trust certificate.
+* CONJ-1082 Multiple session system variables parsing fails
+* CONJ-1083 Using /*client prepare*/ prefix to force client side prepared statement
+* CONJ-1091 can't make a connection when the Read Replica DB is in a hang state when SocketTimeout=0 set
+* CONJ-1092 ensure respecting server collation
+* CONJ-1094 Missing mariadb/mysql collation
+
+
+## [3.0.11](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.0.11) (Aug 2023)
+[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.10...3.0.11)
+
+* CONJ-1089 correcting 3.0.10 incompatibility with in java 8
+
+## [2.7.10](https://github.com/mariadb-corporation/mariadb-connector-j/tree/2.7.10) (Aug 2023)
+[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/2.7.9...2.7.10)
+
+* CONJ-1091 Ensure setting connectTimeout as timeout for socket timeout until connection is done. This permit to set a connectTimeout, while socketTimeout can still be set to 0
+
## [3.1.4](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.1.4) (Apr 2023)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.1.3...3.1.4)
diff --git a/pom.xml b/pom.xml
index ffbaa99e5..116cc8b6a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
mariadb-java-client
jar
mariadb-java-client
- 3.1.4
+ 3.2.0
JDBC driver for MariaDB and MySQL
https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/
diff --git a/src/benchmark/java/org/mariadb/jdbc/Common.java b/src/benchmark/java/org/mariadb/jdbc/Common.java
index 83538ea0e..9d68aee58 100644
--- a/src/benchmark/java/org/mariadb/jdbc/Common.java
+++ b/src/benchmark/java/org/mariadb/jdbc/Common.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/benchmark/java/org/mariadb/jdbc/Do_1.java b/src/benchmark/java/org/mariadb/jdbc/Do_1.java
index 92d164931..7b23d008e 100644
--- a/src/benchmark/java/org/mariadb/jdbc/Do_1.java
+++ b/src/benchmark/java/org/mariadb/jdbc/Do_1.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/benchmark/java/org/mariadb/jdbc/Do_1000_params.java b/src/benchmark/java/org/mariadb/jdbc/Do_1000_params.java
index 6850bce04..0c6e157b6 100644
--- a/src/benchmark/java/org/mariadb/jdbc/Do_1000_params.java
+++ b/src/benchmark/java/org/mariadb/jdbc/Do_1000_params.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/benchmark/java/org/mariadb/jdbc/Insert_batch.java b/src/benchmark/java/org/mariadb/jdbc/Insert_batch.java
index b4ad7db76..7b9ebbcba 100644
--- a/src/benchmark/java/org/mariadb/jdbc/Insert_batch.java
+++ b/src/benchmark/java/org/mariadb/jdbc/Insert_batch.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/benchmark/java/org/mariadb/jdbc/Select_1.java b/src/benchmark/java/org/mariadb/jdbc/Select_1.java
index 2e3f94363..4a5a63815 100644
--- a/src/benchmark/java/org/mariadb/jdbc/Select_1.java
+++ b/src/benchmark/java/org/mariadb/jdbc/Select_1.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/benchmark/java/org/mariadb/jdbc/Select_1000_Rows.java b/src/benchmark/java/org/mariadb/jdbc/Select_1000_Rows.java
index 41babb4f1..a1848381c 100644
--- a/src/benchmark/java/org/mariadb/jdbc/Select_1000_Rows.java
+++ b/src/benchmark/java/org/mariadb/jdbc/Select_1000_Rows.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/benchmark/java/org/mariadb/jdbc/Select_100_cols.java b/src/benchmark/java/org/mariadb/jdbc/Select_100_cols.java
index 98baa2ea5..a4f5a03a8 100644
--- a/src/benchmark/java/org/mariadb/jdbc/Select_100_cols.java
+++ b/src/benchmark/java/org/mariadb/jdbc/Select_100_cols.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/main/java/org/mariadb/jdbc/BaseCallableStatement.java b/src/main/java/org/mariadb/jdbc/BaseCallableStatement.java
index 92d0e3d09..2a9516ae1 100644
--- a/src/main/java/org/mariadb/jdbc/BaseCallableStatement.java
+++ b/src/main/java/org/mariadb/jdbc/BaseCallableStatement.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java b/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java
index 7fbec194d..0d0ec46ea 100644
--- a/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java
+++ b/src/main/java/org/mariadb/jdbc/BasePreparedStatement.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
@@ -13,6 +13,7 @@
import java.sql.ParameterMetaData;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
+import java.util.regex.Pattern;
import org.mariadb.jdbc.client.ColumnDecoder;
import org.mariadb.jdbc.client.util.Parameters;
import org.mariadb.jdbc.codec.*;
@@ -24,6 +25,8 @@
/** Common methods for prepare statement, for client and server prepare statement. */
public abstract class BasePreparedStatement extends Statement implements PreparedStatement {
+ private static final Pattern INSERT_STATEMENT_PATTERN =
+ Pattern.compile("^(\\s*\\/\\*([^*]|\\*[^/])*\\*\\/)*\\s*(INSERT)", Pattern.CASE_INSENSITIVE);
/** parameters */
protected Parameters parameters;
@@ -37,6 +40,8 @@ public abstract class BasePreparedStatement extends Statement implements Prepare
/** PREPARE command result */
protected Prepare prepareResult = null;
+ protected Boolean isCommandInsert = null;
+
/**
* Constructor
*
@@ -91,6 +96,11 @@ public String toString() {
return sb.toString();
}
+ protected void checkIfInsertCommand() {
+ if (isCommandInsert == null)
+ isCommandInsert = (sql == null) ? false : INSERT_STATEMENT_PATTERN.matcher(sql).find();
+ }
+
/**
* Set PREPARE result
*
diff --git a/src/main/java/org/mariadb/jdbc/CallableParameterMetaData.java b/src/main/java/org/mariadb/jdbc/CallableParameterMetaData.java
index f9a0f0c4a..c46e41b44 100644
--- a/src/main/java/org/mariadb/jdbc/CallableParameterMetaData.java
+++ b/src/main/java/org/mariadb/jdbc/CallableParameterMetaData.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
diff --git a/src/main/java/org/mariadb/jdbc/ClientPreparedStatement.java b/src/main/java/org/mariadb/jdbc/ClientPreparedStatement.java
index 683256a9a..ad8197a1e 100644
--- a/src/main/java/org/mariadb/jdbc/ClientPreparedStatement.java
+++ b/src/main/java/org/mariadb/jdbc/ClientPreparedStatement.java
@@ -1,16 +1,13 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
import static org.mariadb.jdbc.util.constants.Capabilities.*;
import java.sql.*;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
+import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import org.mariadb.jdbc.client.ColumnDecoder;
import org.mariadb.jdbc.client.Completion;
@@ -107,12 +104,16 @@ private void executeInternal() throws SQLException {
}
}
- private void executeInternalPreparedBatch() throws SQLException {
+ private boolean executeInternalPreparedBatch() throws SQLException {
checkNotClosed();
- if (autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS
+ checkIfInsertCommand();
+ Configuration conf = con.getContext().getConf();
+ if (((isCommandInsert && (conf.useBulkStmts() || conf.useBulkStmtsForInserts()))
+ || (!isCommandInsert && conf.useBulkStmts()))
&& batchParameters.size() > 1
- && con.getContext().hasClientCapability(STMT_BULK_OPERATIONS)) {
+ && autoGeneratedKeys != Statement.RETURN_GENERATED_KEYS) {
executeBatchBulk();
+ return isCommandInsert;
} else {
boolean possibleLoadLocal = con.getContext().hasClientCapability(LOCAL_FILES);
if (possibleLoadLocal) {
@@ -128,6 +129,7 @@ private void executeInternalPreparedBatch() throws SQLException {
executeBatchPipeline();
}
}
+ return false;
}
/**
@@ -463,8 +465,24 @@ public int[] executeBatch() throws SQLException {
if (batchParameters == null || batchParameters.isEmpty()) return new int[0];
lock.lock();
try {
- executeInternalPreparedBatch();
+ boolean wasBulkInsert = executeInternalPreparedBatch();
+
int[] updates = new int[batchParameters.size()];
+
+ // specific case for BULK INSERT
+ // return not Statement.SUCCESS_NO_INFO, but 1
+ if (wasBulkInsert) {
+ int numberOfResult = 0;
+ for (int i = 0; i < results.size(); i++) {
+ numberOfResult += (int) ((OkPacket) results.get(i)).getAffectedRows();
+ }
+ if (numberOfResult == updates.length) {
+ Arrays.fill(updates, 1);
+ currResult = results.remove(0);
+ return updates;
+ }
+ }
+
if (results.size() != batchParameters.size()) {
for (int i = 0; i < batchParameters.size(); i++) {
updates[i] = Statement.SUCCESS_NO_INFO;
@@ -492,8 +510,23 @@ public long[] executeLargeBatch() throws SQLException {
if (batchParameters == null || batchParameters.isEmpty()) return new long[0];
lock.lock();
try {
- executeInternalPreparedBatch();
+ boolean wasBulkInsert = executeInternalPreparedBatch();
long[] updates = new long[results.size()];
+
+ // specific case for BULK INSERT
+ // return not Statement.SUCCESS_NO_INFO, but 1
+ if (wasBulkInsert) {
+ int numberOfResult = 0;
+ for (int i = 0; i < results.size(); i++) {
+ numberOfResult += (int) ((OkPacket) results.get(i)).getAffectedRows();
+ }
+ if (numberOfResult == updates.length) {
+ Arrays.fill(updates, 1);
+ currResult = results.remove(0);
+ return updates;
+ }
+ }
+
for (int i = 0; i < results.size(); i++) {
updates[i] = ((OkPacket) results.get(i)).getAffectedRows();
}
diff --git a/src/main/java/org/mariadb/jdbc/Configuration.java b/src/main/java/org/mariadb/jdbc/Configuration.java
index 8388b6cca..a43153168 100644
--- a/src/main/java/org/mariadb/jdbc/Configuration.java
+++ b/src/main/java/org/mariadb/jdbc/Configuration.java
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
-// Copyright (c) 2015-2021 MariaDB Corporation Ab
+// Copyright (c) 2015-2023 MariaDB Corporation Ab
package org.mariadb.jdbc;
@@ -15,6 +15,7 @@
import org.mariadb.jdbc.plugin.Codec;
import org.mariadb.jdbc.plugin.CredentialPlugin;
import org.mariadb.jdbc.plugin.credential.CredentialPluginLoader;
+import org.mariadb.jdbc.util.constants.CatalogTerm;
import org.mariadb.jdbc.util.log.Logger;
import org.mariadb.jdbc.util.log.Loggers;
import org.mariadb.jdbc.util.options.OptionAliases;
@@ -58,7 +59,6 @@ public class Configuration {
private String database = null;
private List addresses = null;
private HaMode haMode = HaMode.NONE;
-
private String initialUrl = null;
private Properties nonMappedOptions = null;
@@ -66,7 +66,9 @@ public class Configuration {
private String timezone = null;
private Boolean autocommit = null;
private boolean useMysqlMetadata = false;
+ private CatalogTerm useCatalogTerm = CatalogTerm.UseCatalog;
private boolean createDatabaseIfNotExist = false;
+ private boolean useLocalSessionState = false;
private TransactionIsolation transactionIsolation = null;
private int defaultFetchSize = 0;
private int maxQuerySizeToLog = 1024;
@@ -97,7 +99,9 @@ public class Configuration {
private String serverSslCert = null;
private String keyStore = null;
private String keyStorePassword = null;
+ private String keyPassword = null;
private String keyStoreType = null;
+ private String trustStoreType = null;
private String enabledSslCipherSuites = null;
private String enabledSslProtocolSuites = null;
@@ -106,7 +110,8 @@ public class Configuration {
private boolean allowLocalInfile = true;
private boolean useCompression = false;
private boolean useAffectedRows = false;
- private boolean useBulkStmts = true;
+ private boolean useBulkStmts = false;
+ private boolean useBulkStmtsForInserts = true;
private boolean disablePipeline = false;
// prepare
private boolean cachePrepStmts = true;
@@ -162,7 +167,9 @@ private Configuration(
String timezone,
Boolean autocommit,
boolean useMysqlMetadata,
+ CatalogTerm useCatalogTerm,
boolean createDatabaseIfNotExist,
+ boolean useLocalSessionState,
TransactionIsolation transactionIsolation,
int defaultFetchSize,
int maxQuerySizeToLog,
@@ -188,7 +195,9 @@ private Configuration(
String serverSslCert,
String keyStore,
String keyStorePassword,
+ String keyPassword,
String keyStoreType,
+ String trustStoreType,
String enabledSslCipherSuites,
String enabledSslProtocolSuites,
boolean allowMultiQueries,
@@ -196,6 +205,7 @@ private Configuration(
boolean useCompression,
boolean useAffectedRows,
boolean useBulkStmts,
+ boolean useBulkStmtsForInserts,
boolean disablePipeline,
boolean cachePrepStmts,
int prepStmtCacheSize,
@@ -234,7 +244,9 @@ private Configuration(
this.timezone = timezone;
this.autocommit = autocommit;
this.useMysqlMetadata = useMysqlMetadata;
+ this.useCatalogTerm = useCatalogTerm;
this.createDatabaseIfNotExist = createDatabaseIfNotExist;
+ this.useLocalSessionState = useLocalSessionState;
this.transactionIsolation = transactionIsolation;
this.defaultFetchSize = defaultFetchSize;
this.maxQuerySizeToLog = maxQuerySizeToLog;
@@ -260,7 +272,9 @@ private Configuration(
this.serverSslCert = serverSslCert;
this.keyStore = keyStore;
this.keyStorePassword = keyStorePassword;
+ this.keyPassword = keyPassword;
this.keyStoreType = keyStoreType;
+ this.trustStoreType = trustStoreType;
this.enabledSslCipherSuites = enabledSslCipherSuites;
this.enabledSslProtocolSuites = enabledSslProtocolSuites;
this.allowMultiQueries = allowMultiQueries;
@@ -268,6 +282,7 @@ private Configuration(
this.useCompression = useCompression;
this.useAffectedRows = useAffectedRows;
this.useBulkStmts = useBulkStmts;
+ this.useBulkStmtsForInserts = useBulkStmtsForInserts;
this.disablePipeline = disablePipeline;
this.cachePrepStmts = cachePrepStmts;
this.prepStmtCacheSize = prepStmtCacheSize;
@@ -338,10 +353,13 @@ private Configuration(
Boolean useServerPrepStmts,
String connectionAttributes,
Boolean useBulkStmts,
+ Boolean useBulkStmtsForInserts,
Boolean disablePipeline,
Boolean autocommit,
Boolean useMysqlMetadata,
+ String useCatalogTerm,
Boolean createDatabaseIfNotExist,
+ Boolean useLocalSessionState,
Boolean includeInnodbStatusInDeadlockExceptions,
Boolean includeThreadDumpInDeadlockExceptions,
String servicePrincipalName,
@@ -364,7 +382,9 @@ private Configuration(
String serverSslCert,
String keyStore,
String keyStorePassword,
+ String keyPassword,
String keyStoreType,
+ String trustStoreType,
Boolean useReadAheadInput,
Boolean cachePrepStmts,
Boolean transactionReplay,
@@ -419,10 +439,24 @@ private Configuration(
if (useServerPrepStmts != null) this.useServerPrepStmts = useServerPrepStmts;
this.connectionAttributes = connectionAttributes;
if (useBulkStmts != null) this.useBulkStmts = useBulkStmts;
+ if (useBulkStmtsForInserts != null) this.useBulkStmtsForInserts = useBulkStmtsForInserts;
if (disablePipeline != null) this.disablePipeline = disablePipeline;
if (autocommit != null) this.autocommit = autocommit;
if (useMysqlMetadata != null) this.useMysqlMetadata = useMysqlMetadata;
+ if (useCatalogTerm != null) {
+ if (!"CATALOG".equalsIgnoreCase(useCatalogTerm)
+ && !"SCHEMA".equalsIgnoreCase(useCatalogTerm)) {
+ throw new IllegalArgumentException(
+ "useCatalogTerm can only have CATALOG/SCHEMA value, current set value is "
+ + useCatalogTerm);
+ }
+ this.useCatalogTerm =
+ "CATALOG".equalsIgnoreCase(useCatalogTerm)
+ ? CatalogTerm.UseCatalog
+ : CatalogTerm.UseSchema;
+ }
if (createDatabaseIfNotExist != null) this.createDatabaseIfNotExist = createDatabaseIfNotExist;
+ if (useLocalSessionState != null) this.useLocalSessionState = useLocalSessionState;
if (includeInnodbStatusInDeadlockExceptions != null)
this.includeInnodbStatusInDeadlockExceptions = includeInnodbStatusInDeadlockExceptions;
if (includeThreadDumpInDeadlockExceptions != null)
@@ -460,7 +494,9 @@ private Configuration(
if (serverSslCert != null) this.serverSslCert = serverSslCert;
if (keyStore != null) this.keyStore = keyStore;
if (keyStorePassword != null) this.keyStorePassword = keyStorePassword;
+ if (keyPassword != null) this.keyPassword = keyPassword;
if (keyStoreType != null) this.keyStoreType = keyStoreType;
+ if (trustStoreType != null) this.trustStoreType = trustStoreType;
// *************************************************************
// host primary check
@@ -742,7 +778,9 @@ public Configuration clone(String username, String password) {
this.timezone,
this.autocommit,
this.useMysqlMetadata,
+ this.useCatalogTerm,
this.createDatabaseIfNotExist,
+ this.useLocalSessionState,
this.transactionIsolation,
this.defaultFetchSize,
this.maxQuerySizeToLog,
@@ -768,7 +806,9 @@ public Configuration clone(String username, String password) {
this.serverSslCert,
this.keyStore,
this.keyStorePassword,
+ this.keyPassword,
this.keyStoreType,
+ this.trustStoreType,
this.enabledSslCipherSuites,
this.enabledSslProtocolSuites,
this.allowMultiQueries,
@@ -776,6 +816,7 @@ public Configuration clone(String username, String password) {
this.useCompression,
this.useAffectedRows,
this.useBulkStmts,
+ this.useBulkStmtsForInserts,
this.disablePipeline,
this.cachePrepStmts,
this.prepStmtCacheSize,
@@ -898,6 +939,15 @@ public String keyStorePassword() {
return keyStorePassword;
}
+ /**
+ * key store alias password
+ *
+ * @return key store alias password
+ */
+ public String keyPassword() {
+ return keyPassword;
+ }
+
/**
* key store type (to replace default javax.net.ssl.keyStoreType system property)
*
@@ -907,6 +957,15 @@ public String keyStoreType() {
return keyStoreType;
}
+ /**
+ * trust store type (to replace default javax.net.ssl.keyStoreType system property)
+ *
+ * @return trust store type
+ */
+ public String trustStoreType() {
+ return trustStoreType;
+ }
+
/**
* permitted ssl protocol list (comma separated)
*
@@ -1197,6 +1256,16 @@ public boolean useBulkStmts() {
return useBulkStmts;
}
+ /**
+ * Use server COM_STMT_BULK for batching inserts. if useBulkStmts is enabled,
+ * useBulkStmtsForInserts will be as well
+ *
+ * @return use server bulk command for inserts
+ */
+ public boolean useBulkStmtsForInserts() {
+ return useBulkStmtsForInserts;
+ }
+
/**
* Disable pipeline.
*
@@ -1224,6 +1293,15 @@ public boolean useMysqlMetadata() {
return useMysqlMetadata;
}
+ /**
+ * Indicating using Catalog or Schema
+ *
+ * @return Indicating using Catalog or Schema
+ */
+ public CatalogTerm useCatalogTerm() {
+ return useCatalogTerm;
+ }
+
/**
* create database if not exist
*
@@ -1233,6 +1311,17 @@ public boolean createDatabaseIfNotExist() {
return createDatabaseIfNotExist;
}
+ /**
+ * use local state to avoid unnecessary queries. This means application must use JDBC dedicated
+ * methods, like connection.setTransactionIsolation and never queries like "SET SESSION
+ * TRANSACTION ISOLATION LEVEL X" directly
+ *
+ * @return can use local state
+ */
+ public boolean useLocalSessionState() {
+ return useLocalSessionState;
+ }
+
/**
* On deadlock exception, must driver execute additional commands to show innodb status in error
* description.
@@ -1496,6 +1585,128 @@ public String toString() {
return initialUrl;
}
+ /**
+ * Permit to have string information on how string is parsed. example :
+ * Configuration.toConf("jdbc:mariadb://localhost/test") will return a String containing:
+ * Configuration:
+ * * resulting Url : jdbc:mariadb://localhost/test
+ * Unknown options : None
+ *
+ * Non default options :
+ * * database : test
+ *
+ * default options :
+ * * user : null
+ * ...
+ *
+ *
+ * @param url url string
+ * @return string describing the configuration parsed from url
+ * @throws SQLException if parsing fails
+ */
+ public static String toConf(String url) throws SQLException {
+ Configuration conf = Configuration.parseInternal(url, new Properties());
+ StringBuilder sb = new StringBuilder();
+ StringBuilder sbUnknownOpts = new StringBuilder();
+
+ if (conf.nonMappedOptions.isEmpty()) {
+ sbUnknownOpts.append("None");
+ } else {
+ for (Map.Entry