Skip to content
Commits on Source (7)
<p align="center">
<a href="http://mariadb.org/">
<img src="https://mariadb.com/themes/custom/mariadb/logo.svg">
<a href="http://mariadb.com/">
<img src="https://mariadb.com/kb/static/images/logo-2018-black.png">
</a>
</p>
......@@ -24,7 +24,7 @@ Tracker link <a href="https://jira.mariadb.org/projects/CONJ/issues/">https://ji
|:------------:|:-------------------------:|
| 6 | 1.7.4 |
| 7 | 1.7.4 |
| 8+ | 2.3.0 |
| 8+ | 2.4.2 |
The driver (jar) can be downloaded from [mariadb connector download](https://mariadb.com/products/connectors-plugins)
or maven :
......@@ -32,7 +32,7 @@ or maven :
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.3.0</version>
<version>2.4.0</version>
</dependency>
```
......@@ -50,7 +50,7 @@ Development snapshot are available on sonatype nexus repository
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.3.1-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
```
......
version: '{build}'
environment:
matrix:
- DB: '10.2.16'
- DB: '10.2.24'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- DB: '10.3.8'
- DB: '10.3.15'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- DB: '10.1.34'
- DB: '10.1.40'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- DB: '10.0.35'
- DB: '10.0.38'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
- DB: '5.5.60'
- DB: '5.5.64'
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
CMAKE_PARAM: 'Visual Studio 15 2017 Win64'
JAVA_HOME: C:\Program Files\Java\jdk1.8.0
......@@ -35,7 +35,7 @@ install:
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
}
# Prepend Java entry, remove Ruby entry (C:\Ruby193\bin;) from PATH
- cmd: set FILE=http://mariadb.mirrors.ovh.net/MariaDB/mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
- cmd: set FILE=http://ftp.hosteurope.de/mirror/archive.mariadb.org//mariadb-%DB%/winx64-packages/mariadb-%DB%-winx64.msi
- ps: Start-FileDownload $Env:FILE -FileName server.msi -Timeout 900000
- cmd: msiexec /i server.msi INSTALLDIR=c:\projects\server SERVICENAME=mariadb ALLOWREMOTEROOTACCESS=true /qn
- cmd: "\"c:\\projects\\server\\bin\\mysql.exe\" -e \"create database testj\" --user=root"
......
comment: off
\ No newline at end of file
mariadb-connector-java (2.4.2-1) unstable; urgency=medium
* New upstream release
- Refreshed the patch
- Ignore the jacoco Maven plugin
* Standards-Version updated to 4.4.0
-- Emmanuel Bourg <ebourg@apache.org> Mon, 15 Jul 2019 10:52:39 +0200
mariadb-connector-java (2.3.0-1) unstable; urgency=medium
* New upstream release
......
......@@ -10,7 +10,7 @@ Build-Depends:
libjna-platform-java,
libreplacer-java,
maven-debian-helper (>= 2.1)
Standards-Version: 4.2.1
Standards-Version: 4.4.0
Vcs-Git: https://salsa.debian.org/java-team/mariadb-connector-java.git
Vcs-Browser: https://salsa.debian.org/java-team/mariadb-connector-java
Homepage: https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/
......
......@@ -9,5 +9,6 @@ org.apache.maven.plugins maven-gpg-plugin
org.apache.maven.plugins maven-javadoc-plugin
org.apache.maven.plugins maven-source-plugin
org.codehaus.mojo exec-maven-plugin
org.jacoco jacoco-maven-plugin
org.sonatype.plugins nexus-staging-maven-plugin
pl.project13.maven git-commit-id-plugin
......@@ -3,7 +3,7 @@ Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: not-needed
--- a/pom.xml
+++ b/pom.xml
@@ -123,6 +123,9 @@
@@ -142,6 +142,9 @@
<compilerArgs>
<arg>-Xlint:all,-options,-path</arg>
</compilerArgs>
......@@ -13,18 +13,18 @@ Forwarded: not-needed
</configuration>
</plugin>
--- a/src/main/java/org/mariadb/jdbc/internal/com/send/gssapi/GssUtility.java
+++ b/src/main/java/org/mariadb/jdbc/internal/com/send/gssapi/GssUtility.java
@@ -13,19 +13,6 @@
--- a/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java
+++ b/src/main/java/org/mariadb/jdbc/internal/com/send/authentication/gssapi/GssUtility.java
@@ -11,19 +11,6 @@
* @return authentication method
*/
public static BiFunction<PacketInputStream, Integer, GssapiAuth> getAuthenticationMethod() {
public static GssapiAuth getAuthenticationMethod() {
- try {
- //Waffle-jna has jna as dependency, so if not available on classpath, just use standard authentication
- if (Platform.isWindows()) {
- try {
- Class.forName("waffle.windows.auth.impl.WindowsAuthProviderImpl");
- return (reader, packSeq) -> new WindowsNativeSspiAuthentication(reader, packSeq);
- return new WindowsNativeSspiAuthentication();
- } catch (ClassNotFoundException cle) {
- //waffle not in the classpath
- }
......@@ -32,6 +32,6 @@ Forwarded: not-needed
- } catch (Throwable cle) {
- //jna jar's are not in classpath
- }
return (reader, packSeq) -> new StandardGssapiAuthentication(reader, packSeq);
return new StandardGssapiAuthentication();
}
= Changelog
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#230|2.3.0]] Released on 06 Sep. 2018
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#226|2.2.6]] Released on 19 Jul 2018
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#225|2.2.5]] Released on 29 may 2018
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#224|2.2.4]] Released on 04 may 2018
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#223|2.2.3]] Released on 09 mar. 2018
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#222|2.2.2]] Released on 20 feb. 2018
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#221|2.2.1]] Released on 22 Dec. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#220|2.2.0]] Released on 08 Nov. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#212|2.1.2]] Released on 24 Sept. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#211|2.1.1]] Released on 05 Sept. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#210|2.1.0]] Released on 29 Jul. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#203|2.0.3]] Released on 27 Jun. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#202|2.0.2]] Released on 05 Jun. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#161|1.6.1]] Released on 05 Jun. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#201|2.0.1]] Released on 10 May 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#160|1.6.0]] Released on 10 May 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#200|2.0.0]] Released on 11 Apr. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#158|1.5.9]] Released on 09 Mar. 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#158|1.5.8]] Released on 10 Fev 2017
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#157|1.5.7]] Released on 12 Jan. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#156|1.5.6]] Released on 21 Dec. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#155|1.5.5]] Released on 07 Nov. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#154|1.5.4]] Released on 10 Oct. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#153|1.5.3]] Released on 03 Oct. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#152|1.5.2]] Released on 31 aug. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#151|1.5.1]] RC released on 15 aug. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#150|1.5.0]] RC released on 28 jul. 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#146|1.4.6]] Released on 13 june 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#146|1.4.5]] Released on 18 mai 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#144|1.4.4]] Released on 04 mai 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#143|1.4.3]] Released on 22 april 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#142|1.4.2]] Released on 08 april 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#141|1.4.1]] Released on 07 april 2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#140|1.4.0]] Released on 31 march 2016
---
== 2.3.0
== 2.4.2 - Released on 17 Jun. 2019
Security
* [CONJ-679] parse Query when receiving LOAD LOCAL INFILE
Bugs
* [CONJ-703] ClassNotFoundException when trying to connect using two-authentication in an OSGI environment.
* [CONJ-711] Xid format id is unsigned integer, currently sending as signed value.
* [CONJ-700] autoReconnect=true on Basic Failover doesn't reconnect
* [CONJ-707] failover might throw an unexpected exception with using "failover"/"sequential" configuration on socket error
* [CONJ-709] includeThreadDumpInDeadlockExceptions is thrown only if option includeInnodbStatusInDeadlockExceptions is set
* [CONJ-710] Throw complete stackTrace when having an exception on XA Commands
* [CONJ-714] Error on connection on galera server when in detached mode.
* [CONJ-701] typo in error message in SelectResultSet.java
== 2.4.1 - Released on 15 Mar. 2019
Evolutions
* [misc] enabled running of 'SHOW ENGINE INNODB STATUS' for error code 1213 (@mtykhenko)
* [misc] reduce mutex using select @@innodb_read_only for aurora (@matsuzayaws)
Bugs
* [misc] updating checkstyle version dependency
* [misc] permit using SSL on localsocket
* [CONJ-687] addition of option "useMysqlMetadata" to permit MySQL meta compatibility
* [misc] java PID using java 9 ProcessHandle if existing, relying on JNA if present
* [CONJ-682] internal pool correction: when receiving an RST during connection validation, the pool will end up throwing connection timeout exception in place of reusing another connection.
== 2.4.0 - Released on 28 Jan. 2019
Evolutions
* [CONJ-675] permit multiple alternative authentication methods for the same user (future MariaDB 10.4 feature)
* {CONJ-678] permit indication of truststore/keystore type (JKS/PKCS12), then not relying on java default type
* [CONJ-378] GSSAPI: client can provide SPN
* [CONJ-667] Support MYSQL_TYPE_JSON datatype
* [CONJ-652] faster results buffering socket available
* [CONJ-659] improve text performance reading date/time/timestamp resultset
* [CONJ-670] ability to Refresh SSL certificate
New options
|=useReadAheadInput|use a buffered inputSteam that read socket available data. \\//Default: true//|
|=keyStoreType|indicate key store type (JKS/PKCS12). default is null, then using java default type.|
|=trustStoreType|indicate trust store type (JKS/PKCS12). default is null, then using java default type|
|=servicePrincipalName|when using GSSAPI authentication, SPN (Service Principal Name) use the server SPN information. When set, connector will use this value, ignoring server information|
Bugs
* [CONJ-646] possible NullPointerException when connection lost to database using aurora configuration with one node
* [CONJ-672] batch using multi-send can hang when using query timeout
* [CONJ-544] disable SSL session resumption when using SSL
* [CONJ-589] correcting Clob.length() for utf8mb4
* [CONJ-649] datasource connectTimeout URL parameter is not honoured
* [CONJ-650] Correction on resultset.getObject(columnName, byte[].class) when value is NULL
* [CONJ-665] old MySQL (<5.5.3) doesn't support utf8mb4, using utf8 on 3 bytes as connection charset by default
* [CONJ-671] MariaDb bulk threads occupy full cpu(99%) while db connections broken
* [CONJ-673] abording a connection while fetching a query still does read whole resultset
* [CONJ-669] SQLSyntaxErrorException when querying on empty column name
* [CONJ-674] make dumpQueriesOnException = false by default as per documentation
minor:
* [CONJ-644] small optimization when validating galera connection
* [CONJ-625] add coverage test
* [CONJ-654] DatabaseMetaData.getDriverName() returns connector/J with a lowercase c
== 2.3.0 - 06 Sep. 2018
==== [CONJ-398] Improve deadlock debugging capabilities
......
......@@ -103,12 +103,11 @@ if waffle-jna (and dependencies) is in classpath, native implementation will aut
(This permit to avoid any specific problem with admin right, registry, kinit ...)
Dependencies :
* [[https://maven-badges.herokuapp.com/maven-central/com.github.dblock.waffle/waffle-jna|waffle-jna 1.8.1]]
* [[https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna|jna 4.2.1]]
* [[https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna-platform|jna-platform 4.2.1]]
* [[https://maven-badges.herokuapp.com/maven-central/com.github.dblock.waffle/waffle-jna|waffle-jna 1.9.0]]
* [[https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna|jna 4.5.1]]
* [[https://maven-badges.herokuapp.com/maven-central/net.java.dev.jna/jna-platform|jna-platform 4.5.1]]
* [[https://maven-badges.herokuapp.com/maven-central/org.slf4j/jcl-over-slf4j|jcl-over-slf4j 1.7.14]]
* [[https://maven-badges.herokuapp.com/maven-central/org.slf4j/slf4j-api|slf4j-api 1.7.14]]
* [[https://maven-badges.herokuapp.com/com.google.guava/guava|guava 19.0]]
==Possible errors
......
......@@ -208,10 +208,10 @@ The fastest way to load lots of data is using [[https://mariadb.com/kb/en/mariad
* A "man in the middle" proxy server can change the actual file requested from the server so the client will send a local file to this proxy.
* if someone can execute a query from the client, he can have access to any file on the client (according to the rights of the user running the client process).
A specific option "allowLocalInfile" (default to true) can deactivate functionality on the client side.
A specific option "allowLocalInfile" (default to false) permit to enable functionality on the client side.
The global variable [[server-system-variables#local_infile|local_infile]] can disable LOAD DATA LOCAL INFILE on the server side.
A non-JDBC method can permit using this kind of query without this security issue: The application has to create an InputStream with the file to load. If MariaDbStatement.setLocalInfileInputStream(InputStream inputStream) is set, the inputStream will be sent to the server, replacing the file content (working even with the "allowLocalInfile" option disabled).
A non-JDBC method can permit using this kind of query without this security issue: The application has to create an InputStream with the file to load. If MariaDbStatement.setLocalInfileInputStream(InputStream inputStream) is set, the inputStream will be sent to the server, replacing the file content.
Code example:
{{{
......
......@@ -58,20 +58,20 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>2.3.0</version>
<version>2.4.2</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jna.version>4.2.1</jna.version>
<jna.version>4.5.1</jna.version>
<version.template.file>src/main/resources/Version.java.template</version.template.file>
<version.file>src/main/java/org/mariadb/jdbc/internal/util/constant/Version.java</version.file>
<checkstyleVersion>8.12</checkstyleVersion>
<checkstyleVersion>8.18</checkstyleVersion>
<checkstyle.plugin.version>2.17</checkstyle.plugin.version>
<driver.version.major>2</driver.version.major>
<driver.version.minor>3</driver.version.minor>
<driver.version.patch>0</driver.version.patch>
<driver.version.minor>4</driver.version.minor>
<driver.version.patch>2</driver.version.patch>
<driver.version.qualifier></driver.version.qualifier>
</properties>
......@@ -114,6 +114,25 @@
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
......@@ -130,6 +149,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
......@@ -162,7 +184,7 @@
**/SharedMemorySocket.java,
**/UnixDomainSocket.java,
**/MySQLDataSource.java,
**/org/mariadb/jdbc/internal/com/send/ed25519/**
**/org/mariadb/jdbc/internal/com/send/authentication/ed25519/**
</excludes>
<configLocation>src/test/resources/style.xml</configLocation>
<encoding>UTF-8</encoding>
......@@ -236,35 +258,11 @@
<prefix>git</prefix>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>git</executable>
<arguments>
<argument>archive</argument>
<argument>--format</argument>
<argument>tar.gz</argument>
<argument>--output</argument>
<argument>${project.name}-${git.commit.id.describe}.tar.gz</argument>
<argument>${git.branch}</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<version>3.1.2</version>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
......@@ -275,9 +273,7 @@
<Bundle-SymbolicName>org.mariadb.jdbc</Bundle-SymbolicName>
<Automatic-Module-Name>org.mariadb.jdbc</Automatic-Module-Name>
<Export-Package>org.mariadb.jdbc</Export-Package>
<Import-Package>
javax.naming,javax.management,javax.net;resolution:=optional,javax.net.ssl;resolution:=optional,javax.sql,javax.transaction.xa;resolution:=optional,org.slf4j;resolution:=optional
</Import-Package>
<Import-Package>javax.naming, javax.management, javax.net;resolution:=optional, javax.net.ssl;resolution:=optional, javax.sql, javax.transaction.xa;resolution:=optional, waffle.windows.auth;resolution:=optional, waffle.windows.auth.impl;resolution:=optional, * </Import-Package>
</manifestEntries>
</archive>
</configuration>
......
......@@ -151,11 +151,9 @@ public abstract class BasePrepareStatement extends MariaDbStatement implements P
* one of
* <code>Statement.RETURN_GENERATED_KEYS</code>
* or <code>Statement.NO_GENERATED_KEYS</code>
* @throws SQLException if cannot retrieve auto increment value
*/
public BasePrepareStatement(MariaDbConnection connection, int resultSetScrollType,
int resultSetConcurrency, int autoGeneratedKeys)
throws SQLException {
int resultSetConcurrency, int autoGeneratedKeys) {
super(connection, resultSetScrollType, resultSetConcurrency);
this.noBackslashEscapes = protocol.noBackslashEscapes();
this.useFractionalSeconds = options.useFractionalSeconds;
......@@ -647,14 +645,14 @@ public abstract class BasePrepareStatement extends MariaDbStatement implements P
* <P><B>Note:</B> You must specify the parameter's SQL type.</P>
*
* @param parameterIndex the first parameter is 1, the second is 2, ...
* @param mysqlType the type code defined in <code> ColumnType</code>
* @param mariadbType the type code defined in <code> ColumnType</code>
* @throws SQLException if parameterIndex does not correspond to a parameter
* marker in the SQL statement; if a database access error
* occurs or this method is called on a closed
* <code>PreparedStatement</code>
*/
public void setNull(final int parameterIndex, final ColumnType mysqlType) throws SQLException {
setParameter(parameterIndex, new NullParameter(mysqlType));
public void setNull(final int parameterIndex, final ColumnType mariadbType) throws SQLException {
setParameter(parameterIndex, new NullParameter(mariadbType));
}
/**
......@@ -1026,35 +1024,35 @@ public abstract class BasePrepareStatement extends MariaDbStatement implements P
setString(parameterIndex, obj.toString());
} else if (obj instanceof Clob) {
setClob(parameterIndex, (Clob) obj);
} else if (LocalDateTime.class.isInstance(obj)) {
setTimestamp(parameterIndex, Timestamp.valueOf(LocalDateTime.class.cast(obj)));
} else if (Instant.class.isInstance(obj)) {
setTimestamp(parameterIndex, Timestamp.from(Instant.class.cast(obj)));
} else if (LocalDate.class.isInstance(obj)) {
setDate(parameterIndex, Date.valueOf(LocalDate.class.cast(obj)));
} else if (OffsetDateTime.class.isInstance(obj)) {
} else if (obj instanceof LocalDateTime) {
setTimestamp(parameterIndex, Timestamp.valueOf((LocalDateTime) obj));
} else if (obj instanceof Instant) {
setTimestamp(parameterIndex, Timestamp.from((Instant) obj));
} else if (obj instanceof LocalDate) {
setDate(parameterIndex, Date.valueOf((LocalDate) obj));
} else if (obj instanceof OffsetDateTime) {
setParameter(parameterIndex,
new ZonedDateTimeParameter(
OffsetDateTime.class.cast(obj).toZonedDateTime(),
((OffsetDateTime) obj).toZonedDateTime(),
protocol.getTimeZone().toZoneId(),
useFractionalSeconds,
options));
} else if (OffsetTime.class.isInstance(obj)) {
} else if (obj instanceof OffsetTime) {
setParameter(parameterIndex,
new OffsetTimeParameter(
OffsetTime.class.cast(obj),
(OffsetTime) obj,
protocol.getTimeZone().toZoneId(),
useFractionalSeconds,
options));
} else if (ZonedDateTime.class.isInstance(obj)) {
} else if (obj instanceof ZonedDateTime) {
setParameter(parameterIndex,
new ZonedDateTimeParameter(
ZonedDateTime.class.cast(obj),
(ZonedDateTime) obj,
protocol.getTimeZone().toZoneId(),
useFractionalSeconds,
options));
} else if (LocalTime.class.isInstance(obj)) {
setTime(parameterIndex, Time.valueOf(LocalTime.class.cast(obj)));
} else if (obj instanceof LocalTime) {
setTime(parameterIndex, Time.valueOf((LocalTime) obj));
} else {
//fallback to sending serialized object
setParameter(parameterIndex, new SerializableParameter(obj, noBackslashEscapes));
......@@ -1248,35 +1246,35 @@ public abstract class BasePrepareStatement extends MariaDbStatement implements P
setBinaryStream(parameterIndex, (InputStream) obj, scaleOrLength);
} else if (obj instanceof Reader) {
setCharacterStream(parameterIndex, (Reader) obj, scaleOrLength);
} else if (LocalDateTime.class.isInstance(obj)) {
setTimestamp(parameterIndex, Timestamp.valueOf(LocalDateTime.class.cast(obj)));
} else if (Instant.class.isInstance(obj)) {
setTimestamp(parameterIndex, Timestamp.from(Instant.class.cast(obj)));
} else if (LocalDate.class.isInstance(obj)) {
setDate(parameterIndex, Date.valueOf(LocalDate.class.cast(obj)));
} else if (OffsetDateTime.class.isInstance(obj)) {
} else if (obj instanceof LocalDateTime) {
setTimestamp(parameterIndex, Timestamp.valueOf((LocalDateTime) obj));
} else if (obj instanceof Instant) {
setTimestamp(parameterIndex, Timestamp.from((Instant) obj));
} else if (obj instanceof LocalDate) {
setDate(parameterIndex, Date.valueOf((LocalDate) obj));
} else if (obj instanceof OffsetDateTime) {
setParameter(parameterIndex,
new ZonedDateTimeParameter(
OffsetDateTime.class.cast(obj).toZonedDateTime(),
((OffsetDateTime) obj).toZonedDateTime(),
protocol.getTimeZone().toZoneId(),
useFractionalSeconds,
options));
} else if (OffsetTime.class.isInstance(obj)) {
} else if (obj instanceof OffsetTime) {
setParameter(parameterIndex,
new OffsetTimeParameter(
OffsetTime.class.cast(obj),
(OffsetTime) obj,
protocol.getTimeZone().toZoneId(),
useFractionalSeconds,
options));
} else if (ZonedDateTime.class.isInstance(obj)) {
} else if (obj instanceof ZonedDateTime) {
setParameter(parameterIndex,
new ZonedDateTimeParameter(
ZonedDateTime.class.cast(obj),
(ZonedDateTime) obj,
protocol.getTimeZone().toZoneId(),
useFractionalSeconds,
options));
} else if (LocalTime.class.isInstance(obj)) {
setTime(parameterIndex, Time.valueOf(LocalTime.class.cast(obj)));
} else if (obj instanceof LocalTime) {
setTime(parameterIndex, Time.valueOf((LocalTime) obj));
} else {
throw ExceptionMapper.getSqlException(
"Could not set parameter in setObject, could not convert: " + obj.getClass() + " to "
......
......@@ -79,7 +79,7 @@ import org.mariadb.jdbc.internal.ColumnType;
import org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet;
import org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper;
public abstract class CallableFunctionStatement extends MariaDbPreparedStatementClient implements
public abstract class CallableFunctionStatement extends ClientSidePreparedStatement implements
CallableStatement {
protected CallableParameterMetaData parameterMetadata;
......
......@@ -309,7 +309,7 @@ public class CallableParameterMetaData implements ParameterMetaData {
}
public int getParameterCount() throws SQLException {
public int getParameterCount() {
return params.size();
}
......@@ -380,11 +380,11 @@ public class CallableParameterMetaData implements ParameterMetaData {
return getParam(param).getName();
}
public <T> T unwrap(Class<T> iface) throws SQLException {
public <T> T unwrap(Class<T> iface) {
return null;
}
public boolean isWrapperFor(Class<?> iface) throws SQLException {
public boolean isWrapperFor(Class<?> iface) {
return false;
}
......
......@@ -80,7 +80,7 @@ import org.mariadb.jdbc.internal.ColumnType;
import org.mariadb.jdbc.internal.com.read.resultset.SelectResultSet;
import org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper;
public abstract class CallableProcedureStatement extends MariaDbPreparedStatementServer implements
public abstract class CallableProcedureStatement extends ServerSidePreparedStatement implements
CallableStatement, Cloneable {
/**
......
......@@ -70,10 +70,10 @@ import org.mariadb.jdbc.internal.util.dao.ClientPrepareResult;
import org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper;
public class MariaDbPreparedStatementClient extends BasePrepareStatement {
public class ClientSidePreparedStatement extends BasePrepareStatement {
private static final Logger logger = LoggerFactory
.getLogger(MariaDbPreparedStatementClient.class);
.getLogger(ClientSidePreparedStatement.class);
private final List<ParameterHolder[]> parameterList = new ArrayList<>();
private ClientPrepareResult prepareResult;
private String sqlQuery;
......@@ -99,20 +99,18 @@ public class MariaDbPreparedStatementClient extends BasePrepareStatement {
* or <code>Statement.NO_GENERATED_KEYS</code>
* @throws SQLException exception
*/
public MariaDbPreparedStatementClient(MariaDbConnection connection, String sql,
public ClientSidePreparedStatement(MariaDbConnection connection, String sql,
int resultSetScrollType,
int resultSetConcurrency, int autoGeneratedKeys) throws SQLException {
super(connection, resultSetScrollType, resultSetConcurrency, autoGeneratedKeys);
sqlQuery = sql;
if (prepareResult == null) {
if (options.rewriteBatchedStatements) {
prepareResult = ClientPrepareResult
.rewritableParts(sqlQuery, protocol.noBackslashEscapes());
} else {
prepareResult = ClientPrepareResult.parameterParts(sqlQuery, protocol.noBackslashEscapes());
}
}
parameters = new ParameterHolder[prepareResult.getParamCount()];
}
......@@ -123,9 +121,9 @@ public class MariaDbPreparedStatementClient extends BasePrepareStatement {
* @return Clone statement.
* @throws CloneNotSupportedException if any error occur.
*/
public MariaDbPreparedStatementClient clone(MariaDbConnection connection)
public ClientSidePreparedStatement clone(MariaDbConnection connection)
throws CloneNotSupportedException {
MariaDbPreparedStatementClient clone = (MariaDbPreparedStatementClient) super.clone(connection);
ClientSidePreparedStatement clone = (ClientSidePreparedStatement) super.clone(connection);
clone.sqlQuery = sqlQuery;
clone.prepareResult = prepareResult;
clone.parameters = new ParameterHolder[prepareResult.getParamCount()];
......@@ -214,7 +212,7 @@ public class MariaDbPreparedStatementClient extends BasePrepareStatement {
executeQueryPrologue(false);
results = new Results(this, fetchSize, false, 1, false, resultSetScrollType,
resultSetConcurrency, autoGeneratedKeys,
protocol.getAutoIncrementIncrement());
protocol.getAutoIncrementIncrement(), sqlQuery, parameters);
if (queryTimeout != 0 && canUseServerTimeout) {
//timer will not be used for timeout to avoid having threads
protocol.executeQuery(protocol.isMasterConnection(), results, prepareResult, parameters,
......@@ -295,17 +293,12 @@ public class MariaDbPreparedStatementClient extends BasePrepareStatement {
lock.lock();
try {
executeInternalBatch(size);
results.commandEnd();
return results.getCmdInformation().getUpdateCounts();
} catch (SQLException sqle) {
if (results != null) {
results.commandEnd();
throw executeBatchExceptionEpilogue(sqle, results.getCmdInformation(), size);
}
throw executeBatchExceptionEpilogue(sqle, null, size);
throw executeBatchExceptionEpilogue(sqle, size);
} finally {
executeBatchEpilogue();
lock.unlock();
......@@ -342,17 +335,11 @@ public class MariaDbPreparedStatementClient extends BasePrepareStatement {
lock.lock();
try {
executeInternalBatch(size);
results.commandEnd();
return results.getCmdInformation().getLargeUpdateCounts();
} catch (SQLException sqle) {
if (results != null) {
results.commandEnd();
throw executeBatchExceptionEpilogue(sqle, results.getCmdInformation(), size);
}
throw executeBatchExceptionEpilogue(sqle, null, size);
throw executeBatchExceptionEpilogue(sqle, size);
} finally {
executeBatchEpilogue();
lock.unlock();
......@@ -366,11 +353,9 @@ public class MariaDbPreparedStatementClient extends BasePrepareStatement {
* @throws SQLException if any error occur
*/
private void executeInternalBatch(int size) throws SQLException {
executeQueryPrologue(true);
results = new Results(this, 0, true, size, false, resultSetScrollType,
resultSetConcurrency, autoGeneratedKeys, protocol.getAutoIncrementIncrement());
resultSetConcurrency, autoGeneratedKeys, protocol.getAutoIncrementIncrement(), null, null);
if (protocol
.executeBatchClient(protocol.isMasterConnection(), results, prepareResult, parameterList,
hasLongData)) {
......@@ -502,7 +487,7 @@ public class MariaDbPreparedStatementClient extends BasePrepareStatement {
}
private void loadParametersData() throws SQLSyntaxErrorException {
try (MariaDbPreparedStatementServer ssps = new MariaDbPreparedStatementServer(connection,
try (ServerSidePreparedStatement ssps = new ServerSidePreparedStatement(connection,
sqlQuery,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY,
Statement.NO_GENERATED_KEYS)) {
......
......@@ -102,7 +102,7 @@ public class HostAddress {
* parse - parse server addresses from the URL fragment.
*
* @param spec list of endpoints in one of the forms 1 - host1,....,hostN:port (missing port
* default to MySQL default 3306 2 - host:port,...,host:port
* default to MariaDB default 3306 2 - host:port,...,host:port
* @param haMode High availability mode
* @return parsed endpoints
*/
......@@ -126,7 +126,7 @@ public class HostAddress {
if (!matcher.find()) {
logger.warn("Aurora recommended connection URL must only use cluster end-point like "
+ "\"jdbc:mariadb:aurora//xx.cluster-yy.zz.rds.amazonaws.com\". "
+ "\"jdbc:mariadb:aurora://xx.cluster-yy.zz.rds.amazonaws.com\". "
+ "Using end-point permit auto-discovery of new replicas");
}
}
......
......@@ -133,9 +133,8 @@ public class MariaDbBlob implements Blob, Serializable {
* object.
*
* @return length of the <code>BLOB</code> in bytes
* @throws SQLException if there is an error accessing the length of the <code>BLOB</code>
*/
public long length() throws SQLException {
public long length() {
return length;
}
......@@ -405,10 +404,8 @@ public class MariaDbBlob implements Blob, Serializable {
*
* @param len the length, in bytes, to which the <code>BLOB</code> value that this
* <code>Blob</code> object represents should be truncated
* @throws SQLException if there is an error accessing the <code>BLOB</code> value or if len is
* less than 0
*/
public void truncate(final long len) throws SQLException {
public void truncate(final long len) {
if (len >= 0 && len < this.length) {
this.length = (int) len;
}
......
......@@ -133,7 +133,7 @@ public class MariaDbClob extends MariaDbBlob implements Clob, NClob, Serializabl
}
}
public Reader getCharacterStream() throws SQLException {
public Reader getCharacterStream() {
return new StringReader(toString());
}
......@@ -176,11 +176,11 @@ public class MariaDbClob extends MariaDbBlob implements Clob, NClob, Serializabl
return getBinaryStream();
}
public long position(String searchStr, long start) throws SQLException {
public long position(String searchStr, long start) {
return toString().indexOf(searchStr, (int) start - 1) + 1;
}
public long position(Clob searchStr, long start) throws SQLException {
public long position(Clob searchStr, long start) {
return position(searchStr.toString(), start);
}
......@@ -238,45 +238,97 @@ public class MariaDbClob extends MariaDbBlob implements Clob, NClob, Serializabl
*/
@Override
public long length() {
//The length of a character string is the number of UTF-16 units (not the number of characters)
long len = 0;
for (int i = offset; i < offset + length; ) {
int byteValue = data[i] & 0xff;
if (byteValue < 0x80) {
i += 1;
} else if (byteValue < 0xC2) {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
} else if (byteValue < 0xE0) {
i += 2;
} else if (byteValue < 0xF0) {
i += 3;
} else if (byteValue < 0xF8) {
i += 4;
int pos = offset;
//set ASCII (<= 127 chars)
for (; len < length && data[pos] >= 0; ) {
len++;
pos++;
}
//multi-bytes UTF-8
while (pos < offset + length) {
byte firstByte = data[pos++];
if (firstByte < 0) {
if (firstByte >> 5 != -2 || (firstByte & 30) == 0) {
if (firstByte >> 4 == -2) {
if (pos + 1 < offset + length) {
pos += 2;
len++;
} else {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
}
} else if (firstByte >> 3 != -2) {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
} else if (pos + 2 < offset + length) {
pos += 3;
len += 2;
} else {
//bad truncated UTF8
pos += offset + length;
len += 1;
}
} else {
pos++;
len++;
}
} else {
len++;
}
}
return len;
}
@Override
public void truncate(final long len) throws SQLException {
public void truncate(final long truncateLen) {
//truncate the number of UTF-16 characters
//this can result in a bad UTF-8 string if string finish with a
//character represented in 2 UTF-16
long len = 0;
int pos = offset;
for (; pos < offset + Math.min(length, len); ) {
int byteValue = data[pos] & 0xff;
if (byteValue < 0x80) {
pos += 1;
} else if (byteValue < 0xC2) {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
} else if (byteValue < 0xE0) {
//set ASCII (<= 127 chars)
for (; len < length && len < truncateLen && data[pos] >= 0; ) {
len++;
pos++;
}
//multi-bytes UTF-8
while (pos < offset + length && len < truncateLen) {
byte firstByte = data[pos++];
if (firstByte < 0) {
if (firstByte >> 5 != -2 || (firstByte & 30) == 0) {
if (firstByte >> 4 == -2) {
if (pos + 1 < offset + length) {
pos += 2;
} else if (byteValue < 0xF0) {
len++;
} else {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
}
} else if (firstByte >> 3 != -2) {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
} else if (pos + 2 < offset + length) {
if (len + 2 <= truncateLen) {
pos += 3;
} else if (byteValue < 0xF8) {
pos += 4;
len += 2;
} else {
//truncation will result in bad UTF-8 String
pos += 1;
len = truncateLen;
}
} else {
throw new UncheckedIOException("invalid UTF8", new CharacterCodingException());
}
} else {
pos++;
len++;
}
} else {
len++;
}
}
length = pos - offset;
}
......
......@@ -80,6 +80,7 @@ import java.util.concurrent.Executor;
import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.mariadb.jdbc.internal.logging.Logger;
import org.mariadb.jdbc.internal.logging.LoggerFactory;
import org.mariadb.jdbc.internal.protocol.Protocol;
......@@ -126,11 +127,11 @@ public class MariaDbConnection implements Connection {
*/
private final Options options;
public MariaDbPooledConnection pooledConnection;
protected boolean nullCatalogMeansCurrent = true;
protected boolean nullCatalogMeansCurrent;
private CallableStatementCache callableStatementCache;
private volatile int lowercaseTableNames = -1;
private boolean canUseServerTimeout = false;
private boolean sessionStateAware = true;
private boolean canUseServerTimeout;
private boolean sessionStateAware;
private int stateFlag = 0;
private int defaultTransactionIsolation = 0;
/**
......@@ -223,12 +224,8 @@ public class MariaDbConnection implements Connection {
* <code>ResultSet.CONCUR_UPDATABLE</code>
* @return a new <code>Statement</code> object that will generate <code>ResultSet</code> objects
* with the given type and concurrency
* @throws SQLException if a database access error occurs, this method is called on a closed
* connection or the given parameters are not <code>ResultSet</code>
* constants indicating type and concurrency
*/
public Statement createStatement(final int resultSetType, final int resultSetConcurrency)
throws SQLException {
public Statement createStatement(final int resultSetType, final int resultSetConcurrency) {
return new MariaDbStatement(this, resultSetType, resultSetConcurrency);
}
......@@ -250,21 +247,16 @@ public class MariaDbConnection implements Connection {
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @return a new <code>Statement</code> object that will generate <code>ResultSet</code> objects
* with the given type, concurrency, and holdability
* @throws SQLException if a database access error occurs, this method is
* called on a closed connection or the given parameters
* are not <code>ResultSet</code> constants indicating
* type, concurrency, and holdability
* @see ResultSet
*/
public Statement createStatement(final int resultSetType, final int resultSetConcurrency,
final int resultSetHoldability)
throws SQLException {
final int resultSetHoldability) {
return new MariaDbStatement(this, resultSetType, resultSetConcurrency);
}
private void checkConnection() throws SQLException {
if (protocol.isExplicitClosed()) {
throw new SQLException("createStatement() is called on closed connection");
throw new SQLNonTransientConnectionException("createStatement() is called on closed connection");
}
if (protocol.isClosed() && protocol.getProxy() != null) {
lock.lock();
......@@ -283,9 +275,9 @@ public class MariaDbConnection implements Connection {
* @return a client prepared statement.
* @throws SQLException if there is a problem preparing the statement.
*/
public MariaDbPreparedStatementClient clientPrepareStatement(final String sql)
public ClientSidePreparedStatement clientPrepareStatement(final String sql)
throws SQLException {
return new MariaDbPreparedStatementClient(this,
return new ClientSidePreparedStatement(this,
sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
......@@ -299,9 +291,9 @@ public class MariaDbConnection implements Connection {
* @return a server prepared statement.
* @throws SQLException if there is a problem preparing the statement.
*/
public MariaDbPreparedStatementServer serverPrepareStatement(final String sql)
public ServerSidePreparedStatement serverPrepareStatement(final String sql)
throws SQLException {
return new MariaDbPreparedStatementServer(this,
return new ServerSidePreparedStatement(this,
sql,
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY,
......@@ -385,12 +377,10 @@ public class MariaDbConnection implements Connection {
final int resultSetType,
final int resultSetConcurrency,
final int resultSetHoldability) throws SQLException {
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
throw ExceptionMapper.getFeatureNotSupportedException("Only read-only result sets allowed");
}
//TODO : implement parameters
// resultSetType is ignored since we always are scroll insensitive
return prepareStatement(sql);
return internalPrepareStatement(sql,
resultSetType,
resultSetConcurrency,
Statement.NO_GENERATED_KEYS);
}
/**
......@@ -538,7 +528,7 @@ public class MariaDbConnection implements Connection {
//prepare isn't delayed -> if prepare fail, fallback to client preparedStatement?
checkConnection();
try {
return new MariaDbPreparedStatementServer(this,
return new ServerSidePreparedStatement(this,
sqlQuery,
resultSetScrollType,
resultSetConcurrency,
......@@ -550,7 +540,7 @@ public class MariaDbConnection implements Connection {
//will use clientPreparedStatement
}
}
return new MariaDbPreparedStatementClient(this,
return new ClientSidePreparedStatement(this,
sqlQuery,
resultSetScrollType,
resultSetConcurrency,
......@@ -626,7 +616,7 @@ public class MariaDbConnection implements Connection {
String procedureName = matcher.group(13);
String arguments = matcher.group(16);
if (database == null && sessionStateAware) {
database = getDatabase();
database = protocol.getDatabase();
}
if (database != null && options.cacheCallableStmts) {
......@@ -732,7 +722,7 @@ public class MariaDbConnection implements Connection {
* @throws SQLException if there is an error
*/
public boolean getAutoCommit() throws SQLException {
return protocol != null && protocol.getAutocommit();
return protocol.getAutocommit();
}
/**
......@@ -758,10 +748,9 @@ public class MariaDbConnection implements Connection {
* @throws SQLException if there is an error commiting.
*/
public void commit() throws SQLException {
if (!getAutoCommit()) {
lock.lock();
try {
if (!getAutoCommit() && protocol.inTransaction()) {
if (protocol.inTransaction()) {
try (Statement st = createStatement()) {
st.execute("COMMIT");
}
......@@ -770,7 +759,6 @@ public class MariaDbConnection implements Connection {
lock.unlock();
}
}
}
/**
* Rolls back a transaction.
......@@ -778,10 +766,9 @@ public class MariaDbConnection implements Connection {
* @throws SQLException if there is an error rolling back.
*/
public void rollback() throws SQLException {
if (!getAutoCommit()) {
lock.lock();
try {
if (!getAutoCommit() && protocol.inTransaction()) {
if (protocol.inTransaction()) {
try (Statement st = createStatement()) {
st.execute("ROLLBACK");
}
......@@ -790,7 +777,6 @@ public class MariaDbConnection implements Connection {
lock.unlock();
}
}
}
/**
* <p>Undoes all changes made after the given <code>Savepoint</code> object was set.</p>
......@@ -831,9 +817,8 @@ public class MariaDbConnection implements Connection {
* checks if the connection is closed.
*
* @return true if the connection is closed
* @throws SQLException if the connection cannot be closed.
*/
public boolean isClosed() throws SQLException {
public boolean isClosed() {
return protocol.isClosed();
}
......@@ -841,14 +826,9 @@ public class MariaDbConnection implements Connection {
* returns the meta data about the database.
*
* @return meta data about the db.
* @throws SQLException if there is a problem creating the meta data.
*/
public DatabaseMetaData getMetaData() throws SQLException {
UrlParser urlParser = protocol.getUrlParser();
return new MariaDbDatabaseMetaData(
this,
urlParser.getUsername(),
urlParser.getInitialUrl());
public DatabaseMetaData getMetaData() {
return new MariaDbDatabaseMetaData(this, protocol.getUrlParser());
}
/**
......@@ -878,7 +858,7 @@ public class MariaDbConnection implements Connection {
stateFlag |= ConnectionState.STATE_READ_ONLY;
protocol.setReadonly(readOnly);
} catch (SQLException e) {
ExceptionMapper.throwException(e, this, null);
throw ExceptionMapper.getException(e, this, null, false);
}
}
......@@ -898,7 +878,7 @@ public class MariaDbConnection implements Connection {
* <p>Sets the given catalog name in order to select a subspace of this <code>Connection</code>
* object's database in which to work.</p>
* <p>If the driver does not support catalogs, it will silently ignore this request.</p>
* MySQL treats catalogs and databases as equivalent
* MariaDB treats catalogs and databases as equivalent
*
* @param catalog the name of a catalog (subspace in this <code>Connection</code> object's
* database) in which to work
......@@ -914,7 +894,7 @@ public class MariaDbConnection implements Connection {
stateFlag |= ConnectionState.STATE_DATABASE;
protocol.setCatalog(catalog);
} catch (SQLException e) {
ExceptionMapper.throwException(e, this, null);
throw ExceptionMapper.getException(e, this, null, false);
}
}
......@@ -938,7 +918,7 @@ public class MariaDbConnection implements Connection {
* @see #setTransactionIsolation
*/
public int getTransactionIsolation() throws SQLException {
try (Statement stmt = createStatement()) {
Statement stmt = createStatement();
String sql = "SELECT @@tx_isolation";
if (!protocol.isServerMariaDb()) {
......@@ -948,7 +928,7 @@ public class MariaDbConnection implements Connection {
}
}
try (ResultSet rs = stmt.executeQuery(sql)) {
ResultSet rs = stmt.executeQuery(sql);
if (rs.next()) {
final String response = rs.getString(1);
switch (response) {
......@@ -965,20 +945,8 @@ public class MariaDbConnection implements Connection {
return Connection.TRANSACTION_SERIALIZABLE;
default:
if (!protocol.isServerMariaDb()) {
if ((protocol.getMajorServerVersion() >= 8 && protocol
.versionGreaterOrEqual(8, 0, 3))
|| (protocol.getMajorServerVersion() < 8 && protocol
.versionGreaterOrEqual(5, 7, 20))) {
throw ExceptionMapper
.getSqlException("Could not get transaction isolation level: "
+ "Invalid @@transaction_isolation value \"" + response + "\"");
}
}
throw ExceptionMapper.getSqlException("Could not get transaction isolation level: "
+ "Invalid @@tx_isolation value \"" + response + "\"");
}
}
+ "Invalid value \"" + response + "\"");
}
}
throw ExceptionMapper.getSqlException("Could not get transaction isolation level");
......@@ -1009,7 +977,7 @@ public class MariaDbConnection implements Connection {
stateFlag |= ConnectionState.STATE_TRANSACTION_ISOLATION;
protocol.setTransactionIsolation(level);
} catch (SQLException e) {
ExceptionMapper.throwException(e, this, null);
throw ExceptionMapper.getException(e, this, null, false);
}
}
......@@ -1085,13 +1053,11 @@ public class MariaDbConnection implements Connection {
*
* @return the <code>java.util.Map</code> object associated with this <code>Connection</code>
* object
* @throws SQLException if a database access error occurs or this method is
* called on a closed connection
* @see #setTypeMap
* @since 1.2
*/
public Map<String, Class<?>> getTypeMap() throws SQLException {
return null;
public Map<String, Class<?>> getTypeMap() {
return new HashMap<>();
}
/**
......@@ -1117,14 +1083,12 @@ public class MariaDbConnection implements Connection {
*
* @return the holdability, one of <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @throws SQLException if a database access error occurs or this method is called on a closed
* connection
* @see #setHoldability
* @see DatabaseMetaData#getResultSetHoldability
* @see ResultSet
* @since 1.4
*/
public int getHoldability() throws SQLException {
public int getHoldability() {
return ResultSet.HOLD_CURSORS_OVER_COMMIT;
}
......@@ -1137,15 +1101,12 @@ public class MariaDbConnection implements Connection {
* @param holdability a <code>ResultSet</code> holdability constant; one of
* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or
* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>
* @throws SQLException if a database access occurs, this method is called on a
* closed connection, or the given parameter is not a
* <code>ResultSet</code> constant indicating holdability
* @see #getHoldability
* @see DatabaseMetaData#getResultSetHoldability
* @see ResultSet
*/
@Override
public void setHoldability(final int holdability) throws SQLException {
public void setHoldability(final int holdability) {
//not handled
}
......@@ -1219,12 +1180,8 @@ public class MariaDbConnection implements Connection {
* <code>Clob</code> interface may be used to add data to the <code>Clob</code>.
*
* @return An object that implements the <code>Clob</code> interface
* @throws SQLException if an object that implements the <code>Clob</code>
* interface can not be constructed, this method is called
* on a closed connection or a database access error
* occurs.
*/
public Clob createClob() throws SQLException {
public Clob createClob() {
return new MariaDbClob();
}
......@@ -1234,12 +1191,8 @@ public class MariaDbConnection implements Connection {
* of the <code>Blob</code> interface may be used to add data to the <code>Blob</code>.
*
* @return An object that implements the <code>Blob</code> interface
* @throws SQLException if an object that implements the <code>Blob</code>
* interface can not be constructed, this method is called
* on a closed connection or a database access error
* occurs.
*/
public Blob createBlob() throws SQLException {
public Blob createBlob() {
return new MariaDbBlob();
}
......@@ -1250,12 +1203,8 @@ public class MariaDbConnection implements Connection {
* <code>NClob</code> interface may be used to add data to the <code>NClob</code>.
*
* @return An object that implements the <code>NClob</code> interface
* @throws SQLException if an object that implements the <code>NClob</code>
* interface can not be constructed, this method is called
* on a closed connection or a database access error
* occurs.
*/
public NClob createNClob() throws SQLException {
public NClob createNClob() {
return new MariaDbClob();
}
......@@ -1624,11 +1573,9 @@ public class MariaDbConnection implements Connection {
* @param iface a Class defining an interface.
* @return true if this implements the interface or directly or indirectly wraps an object that
* does.
* @throws SQLException if an error occurs while determining whether this is a wrapper for an
* object with the given interface.
* @since 1.6
*/
public boolean isWrapperFor(final Class<?> iface) throws SQLException {
public boolean isWrapperFor(final Class<?> iface) {
return iface.isInstance(this);
}
......@@ -1637,6 +1584,7 @@ public class MariaDbConnection implements Connection {
*
* @return the username.
*/
@Deprecated
public String getUsername() {
return protocol.getUsername();
}
......@@ -1646,6 +1594,7 @@ public class MariaDbConnection implements Connection {
*
* @return the hostname.
*/
@Deprecated
public String getHostname() {
return protocol.getHost();
}
......@@ -1655,19 +1604,11 @@ public class MariaDbConnection implements Connection {
*
* @return the port
*/
@Deprecated
public int getPort() {
return protocol.getPort();
}
/**
* returns the database.
*
* @return the database
*/
private String getDatabase() {
return protocol.getDatabase();
}
protected boolean getPinGlobalTxToPhysicalConnection() {
return protocol.getPinGlobalTxToPhysicalConnection();
}
......@@ -1733,19 +1674,15 @@ public class MariaDbConnection implements Connection {
* @throws SQLException if database socket error occur
*/
public int getNetworkTimeout() throws SQLException {
try {
return this.protocol.getTimeout();
} catch (SocketException se) {
throw ExceptionMapper.getSqlException("Cannot retrieve the network timeout", se);
}
}
public String getSchema() throws SQLException {
public String getSchema() {
// We support only catalog
return null;
}
public void setSchema(String arg0) throws SQLException {
public void setSchema(String arg0) {
// We support only catalog, and JDBC indicate "If the driver does not support schemas, it will silently ignore this request."
}
......@@ -1780,7 +1717,7 @@ public class MariaDbConnection implements Connection {
}
public long getServerThreadId() {
return (protocol != null) ? protocol.getServerThreadId() : -1;
return protocol.getServerThreadId();
}
public boolean canUseServerTimeout() {
......@@ -1850,6 +1787,6 @@ public class MariaDbConnection implements Connection {
}
public boolean includeThreadsTraces() {
return options.includeInnodbStatusInDeadlockExceptions;
return options.includeThreadDumpInDeadlockExceptions;
}
}