Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Oct 15, 2024
2 parents a788d40 + 24fa865 commit 7d66c42
Show file tree
Hide file tree
Showing 28 changed files with 703 additions and 107 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
# Change Log

## [3.5.0](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.5.0) (Oct 2024)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.4.1...3.5.0)

#### Notable changes

* CONJ-1193 Parsec authentication implementation
* CONJ-1183 permit setting specific truststore

#### Bugs Fixed

* CONJ-1202 Session variable setting must be executed last
* CONJ-1201 incorrect default behavior for forceConnectionTimeZoneToSession
* CONJ-1200 Batch import fails with exception "Unknown command"
* CONJ-1199 option `connectionCollation` addition in order to force collation
* CONJ-1187 Use different exception type for connection timeouts

## [3.4.1](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.4.1) (Jul 2024)
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.4.0...3.4.1)

##### Bugs Fixed

* CONJ-1181 Ensure Prepare cache use schema
* CONJ-1178 DatabaseMetaData.getImportedKeys return different PK_NAME value than getExportedKeys.
* CONJ-1180 Correct DatabaseMeta.getExportedKeys() performances
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Tracker link <a href="https://jira.mariadb.org/projects/CONJ/issues/">https://ji

## Status

[![Linux Build](https://travis-ci.com/mariadb-corporation/mariadb-connector-j.svg?branch=master)](https://app.travis-ci.com/github/mariadb-corporation/mariadb-connector-j)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.mariadb.jdbc/mariadb-java-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mariadb.jdbc/mariadb-java-client)
[![Linux Build](https://app.travis-ci.com/mariadb-corporation/mariadb-connector-j.svg?branch=master)](https://app.travis-ci.com/github/mariadb-corporation/mariadb-connector-j)
[![Maven Central](https://img.shields.io/maven-central/v/org.mariadb.jdbc/mariadb-java-client.svg)](https://maven-badges.herokuapp.com/maven-central/org.mariadb.jdbc/mariadb-java-client)
[![License (LGPL version 2.1)](https://img.shields.io/badge/license-GNU%20LGPL%20version%202.1-green.svg?style=flat-square)](http://opensource.org/licenses/LGPL-2.1)
[![codecov][codecov-image]][codecov-url]

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>3.4.1</version>
<version>3.5.0</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

Expand Down
9 changes: 0 additions & 9 deletions src/main/java/org/mariadb/jdbc/BasePreparedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,6 @@ public void updateMeta(ColumnDecoder[] ci) {

public abstract ParameterMetaData getParameterMetaData() throws SQLException;

/**
* Set all parameters
*
* @param parameters parameters
*/
public void setParameters(Parameters parameters) {
this.parameters = parameters;
}

/**
* Set parameter
*
Expand Down
132 changes: 124 additions & 8 deletions src/main/java/org/mariadb/jdbc/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Configuration {

// various
private String timezone = null;
private String connectionCollation = null;
private String connectionTimeZone = null;
private Boolean forceConnectionTimeZoneToSession = null;
private boolean preserveInstants;
Expand Down Expand Up @@ -105,7 +106,9 @@ public class Configuration {
private SslMode sslMode = SslMode.DISABLE;
private String serverSslCert = null;
private String keyStore = null;
private String trustStore = null;
private String keyStorePassword = null;
private String trustStorePassword = null;
private String keyPassword = null;
private String keyStoreType = null;
private String trustStoreType = null;
Expand Down Expand Up @@ -174,6 +177,7 @@ private Configuration(
Properties nonMappedOptions,
String timezone,
String connectionTimeZone,
String connectionCollation,
boolean forceConnectionTimeZoneToSession,
boolean preserveInstants,
Boolean autocommit,
Expand Down Expand Up @@ -210,7 +214,9 @@ private Configuration(
SslMode sslMode,
String serverSslCert,
String keyStore,
String trustStore,
String keyStorePassword,
String trustStorePassword,
String keyPassword,
String keyStoreType,
String trustStoreType,
Expand Down Expand Up @@ -261,6 +267,7 @@ private Configuration(
this.nonMappedOptions = nonMappedOptions;
this.timezone = timezone;
this.connectionTimeZone = connectionTimeZone;
this.connectionCollation = connectionCollation;
this.forceConnectionTimeZoneToSession = forceConnectionTimeZoneToSession;
this.preserveInstants = preserveInstants;
this.autocommit = autocommit;
Expand Down Expand Up @@ -297,7 +304,9 @@ private Configuration(
this.sslMode = sslMode;
this.serverSslCert = serverSslCert;
this.keyStore = keyStore;
this.trustStore = trustStore;
this.keyStorePassword = keyStorePassword;
this.trustStorePassword = trustStorePassword;
this.keyPassword = keyPassword;
this.keyStoreType = keyStoreType;
this.trustStoreType = trustStoreType;
Expand Down Expand Up @@ -378,6 +387,7 @@ private Configuration(
Boolean yearIsDateType,
String timezone,
String connectionTimeZone,
String connectionCollation,
Boolean forceConnectionTimeZoneToSession,
Boolean preserveInstants,
Boolean dumpQueriesOnException,
Expand Down Expand Up @@ -419,7 +429,9 @@ private Configuration(
Boolean allowPublicKeyRetrieval,
String serverSslCert,
String keyStore,
String trustStore,
String keyStorePassword,
String trustStorePassword,
String keyPassword,
String keyStoreType,
String trustStoreType,
Expand Down Expand Up @@ -475,6 +487,7 @@ private Configuration(
if (yearIsDateType != null) this.yearIsDateType = yearIsDateType;
this.timezone = timezone;
if (connectionTimeZone != null) this.connectionTimeZone = connectionTimeZone;
if (connectionCollation != null) this.connectionCollation = connectionCollation;
if (forceConnectionTimeZoneToSession != null)
this.forceConnectionTimeZoneToSession = forceConnectionTimeZoneToSession;
if (preserveInstants != null) this.preserveInstants = preserveInstants;
Expand Down Expand Up @@ -555,7 +568,9 @@ private Configuration(
if (initSql != null) this.initSql = initSql;
if (serverSslCert != null) this.serverSslCert = serverSslCert;
if (keyStore != null) this.keyStore = keyStore;
if (trustStore != null) this.trustStore = trustStore;
if (keyStorePassword != null) this.keyStorePassword = keyStorePassword;
if (trustStorePassword != null) this.trustStorePassword = trustStorePassword;
if (keyPassword != null) this.keyPassword = keyPassword;
if (keyStoreType != null) this.keyStoreType = keyStoreType;
if (trustStoreType != null) this.trustStoreType = trustStoreType;
Expand Down Expand Up @@ -618,6 +633,24 @@ private Configuration(
// option value verification
// *************************************************************

// ensure connection collation format
if (connectionCollation != null) {
if ("".equals(connectionCollation.trim())) {
this.connectionCollation = null;
} else {
// ensure this is an utf8mb4 collation
if (!connectionCollation.toLowerCase(Locale.ROOT).startsWith("utf8mb4_")) {
throw new SQLException(
String.format(
"wrong connection collation '%s' only utf8mb4 collation are accepted",
connectionCollation));
} else if (!connectionCollation.matches("^[a-zA-Z0-9_]+$")) {
throw new SQLException(
String.format("wrong connection collation '%s' name", connectionCollation));
}
}
}

// int fields must all be positive
Field[] fields = Configuration.class.getDeclaredFields();
try {
Expand Down Expand Up @@ -651,6 +684,7 @@ public Builder toBuilder() {
.haMode(this.haMode)
.timezone(this.timezone)
.connectionTimeZone(this.connectionTimeZone)
.connectionCollation(this.connectionCollation)
.forceConnectionTimeZoneToSession(this.forceConnectionTimeZoneToSession)
.preserveInstants(this.preserveInstants)
.autocommit(this.autocommit)
Expand Down Expand Up @@ -689,8 +723,10 @@ public Builder toBuilder() {
.sslMode(this.sslMode.name())
.serverSslCert(this.serverSslCert)
.keyStore(this.keyStore)
.trustStore(this.trustStore)
.keyStoreType(this.keyStoreType)
.keyStorePassword(this.keyStorePassword)
.trustStorePassword(this.trustStorePassword)
.keyPassword(this.keyPassword)
.trustStoreType(this.trustStoreType)
.enabledSslCipherSuites(this.enabledSslCipherSuites)
Expand Down Expand Up @@ -799,7 +835,12 @@ private static Configuration parseInternal(String url, Properties properties)
int skipPos;
int posToSkip = 0;
while ((skipPos = urlSecondPart.indexOf("address=(", posToSkip)) > -1) {
posToSkip = urlSecondPart.indexOf(")", skipPos);
posToSkip = urlSecondPart.indexOf(")", skipPos) + 1;
while (urlSecondPart.startsWith("(", posToSkip)) {
int endingBraceIndex = urlSecondPart.indexOf(")", posToSkip);
if (endingBraceIndex == -1) break;
posToSkip = endingBraceIndex + 1;
}
}
int dbIndex = urlSecondPart.indexOf("/", posToSkip);
int paramIndex = urlSecondPart.indexOf("?");
Expand Down Expand Up @@ -1043,13 +1084,18 @@ public static String toConf(String url) throws SQLException {
case "Integer":
case "SslMode":
case "CatalogTerm":
(Objects.equals(fieldValue, field.get(defaultConf))
StringBuilder sbb =
(Objects.equals(fieldValue, field.get(defaultConf))
? sbDefaultOpts
: sbDifferentOpts)
.append("\n * ")
.append(field.getName())
.append(" : ")
.append(fieldValue);
: sbDifferentOpts);

sbb.append("\n * ").append(field.getName()).append(" : ");
if ("password".equals(field.getName())
|| "keyStorePassword".equals(field.getName())
|| "trustStorePassword".equals(field.getName())) {
sbb.append("***");
} else sbb.append(fieldValue);

break;
case "ArrayList":
(Objects.equals(fieldValue.toString(), field.get(defaultConf).toString())
Expand Down Expand Up @@ -1144,7 +1190,9 @@ protected static String buildUrl(Configuration conf) {

if (obj != null && (!(obj instanceof Properties) || ((Properties) obj).size() > 0)) {

if ("password".equals(field.getName())) {
if ("password".equals(field.getName())
|| "keyStorePassword".equals(field.getName())
|| "trustStorePassword".equals(field.getName())) {
sb.append(first ? '?' : '&');
first = false;
sb.append(field.getName()).append('=');
Expand Down Expand Up @@ -1335,6 +1383,15 @@ public String keyStore() {
return keyStore;
}

/**
* trust store
*
* @return trust store
*/
public String trustStore() {
return trustStore;
}

/**
* key store password
*
Expand All @@ -1344,6 +1401,15 @@ public String keyStorePassword() {
return keyStorePassword;
}

/**
* trust store password
*
* @return trust store password
*/
public String trustStorePassword() {
return trustStorePassword;
}

/**
* key store alias password
*
Expand Down Expand Up @@ -1635,6 +1701,15 @@ public String connectionTimeZone() {
return connectionTimeZone;
}

/**
* get connectionCollation
*
* @return connectionCollation
*/
public String connectionCollation() {
return connectionCollation;
}

/**
* forceConnectionTimeZoneToSession must connection timezone be forced
*
Expand Down Expand Up @@ -2124,6 +2199,7 @@ public static final class Builder implements Cloneable {
// various
private String timezone;
private String connectionTimeZone;
private String connectionCollation;
private Boolean forceConnectionTimeZoneToSession;
private Boolean preserveInstants;
private Boolean autocommit;
Expand Down Expand Up @@ -2164,7 +2240,9 @@ public static final class Builder implements Cloneable {
private String sslMode;
private String serverSslCert;
private String keyStore;
private String trustStore;
private String keyStorePassword;
private String trustStorePassword;
private String keyPassword;
private String keyStoreType;
private String trustStoreType;
Expand Down Expand Up @@ -2256,6 +2334,18 @@ public Builder keyStore(String keyStore) {
return this;
}

/**
* File path of the trustStore file that contain trusted certificates (similar to java System
* property \"javax.net.ssl.trustStore\")
*
* @param trustStore client trust store certificates
* @return this {@link Builder}
*/
public Builder trustStore(String trustStore) {
this.trustStore = nullOrEmpty(trustStore);
return this;
}

/**
* Client keystore password
*
Expand All @@ -2267,6 +2357,17 @@ public Builder keyStorePassword(String keyStorePassword) {
return this;
}

/**
* Client truststore password
*
* @param trustStorePassword client truststore password
* @return this {@link Builder}
*/
public Builder trustStorePassword(String trustStorePassword) {
this.trustStorePassword = nullOrEmpty(trustStorePassword);
return this;
}

/**
* Client keystore alias password
*
Expand Down Expand Up @@ -2803,6 +2904,18 @@ public Builder connectionTimeZone(String connectionTimeZone) {
return this;
}

/**
* indicate what utf8mb4 collation to use. if not set, server default collation for utf8mb4 will
* be used
*
* @param connectionCollation utf8mb4 collation to use
* @return this {@link Builder}
*/
public Builder connectionCollation(String connectionCollation) {
this.connectionCollation = nullOrEmpty(connectionCollation);
return this;
}

/**
* Indicate if connectionTimeZone must be forced to session
*
Expand Down Expand Up @@ -3345,6 +3458,7 @@ public Configuration build() throws SQLException {
this.yearIsDateType,
this.timezone,
this.connectionTimeZone,
this.connectionCollation,
this.forceConnectionTimeZoneToSession,
this.preserveInstants,
this.dumpQueriesOnException,
Expand Down Expand Up @@ -3386,7 +3500,9 @@ public Configuration build() throws SQLException {
this.allowPublicKeyRetrieval,
this.serverSslCert,
this.keyStore,
this.trustStore,
this.keyStorePassword,
this.trustStorePassword,
this.keyPassword,
this.keyStoreType,
this.trustStoreType,
Expand Down
Loading

0 comments on commit 7d66c42

Please sign in to comment.