Skip to content

Commit

Permalink
Merge branch 'release/1.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Aug 30, 2016
2 parents 051e0cf + a7c081e commit 889863a
Show file tree
Hide file tree
Showing 44 changed files with 515 additions and 277 deletions.
51 changes: 26 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,34 @@ sudo: required
language: java
before_install:
- chmod +x .travis/before_test.sh
- chmod +x .travis/script.sh
install: .travis/before_test.sh
jdk:
- oraclejdk8
- oraclejdk7
env:
- AURORA=true SINGLEHOST=false
- MARIA_VERSION=5.5 MAX_ALLOWED_PACKET=8M INNODB_LOG_FILE_SIZE=80M SINGLEHOST=true
- MARIA_VERSION=5.5 MAX_ALLOWED_PACKET=20M INNODB_LOG_FILE_SIZE=200M SINGLEHOST=true
- MARIA_VERSION=5.5 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- MARIA_VERSION=10.0 MAX_ALLOWED_PACKET=8M INNODB_LOG_FILE_SIZE=80M SINGLEHOST=true
- MARIA_VERSION=10.0 MAX_ALLOWED_PACKET=20M INNODB_LOG_FILE_SIZE=200M SINGLEHOST=true
- MARIA_VERSION=10.0 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=8M INNODB_LOG_FILE_SIZE=80M SINGLEHOST=true
- MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=20M INNODB_LOG_FILE_SIZE=200M SINGLEHOST=true
- MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- TYPE=REWRITE MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- TYPE=MULTI MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- TYPE=BULK_CLIENT MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- TYPE=NO_BULK_CLIENT MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- TYPE=NO_BULK_SERVER MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- COMPRESSION=true MARIA_VERSION=10.1 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- TYPE=NO_BULK_SERVER MARIA_VERSION=10.2 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- COMPRESSION=true MARIA_VERSION=10.2 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- MYSQL_VERSION=5.7 MAX_ALLOWED_PACKET=8M INNODB_LOG_FILE_SIZE=80M SINGLEHOST=true
- MYSQL_VERSION=5.7 MAX_ALLOWED_PACKET=20M INNODB_LOG_FILE_SIZE=200M SINGLEHOST=true
- MYSQL_VERSION=5.7 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
- MYSQL_VERSION=5.6 MAX_ALLOWED_PACKET=8M INNODB_LOG_FILE_SIZE=80M SINGLEHOST=true
- MYSQL_VERSION=5.6 MAX_ALLOWED_PACKET=20M INNODB_LOG_FILE_SIZE=200M SINGLEHOST=true
- MYSQL_VERSION=5.6 MAX_ALLOWED_PACKET=40M INNODB_LOG_FILE_SIZE=400M SINGLEHOST=true
script: mvn clean test $URLSTRING -DtestSingleHost=$SINGLEHOST $ADDITIONNAL_VARIABLES -DjobId=$TRAVIS_JOB_ID -DkeystorePath="/etc/mysql/client-keystore.p12" -DkeystorePassword="kspass"
- AURORA=true
- MARIA=5.5 PACKET=8M
- MARIA=5.5 PACKET=20M
- MARIA=5.5 PACKET=40M
- MARIA=10.0 PACKET=8M
- MARIA=10.0 PACKET=20M
- MARIA=10.0 PACKET=40M
- MARIA=10.1 PACKET=8M
- MARIA=10.1 PACKET=20M
- MARIA=10.1 PACKET=40M
- TYPE=REWRITE MARIA=10.1 PACKET=40M
- TYPE=MULTI MARIA=10.1 PACKET=40M
- TYPE=BULK_CLIENT MARIA=10.1 PACKET=40M
- TYPE=NO_BULK_CLIENT MARIA=10.1 PACKET=40M
- TYPE=NO_BULK_SERVER MARIA=10.1 PACKET=40M
- COMPRESSION=false MARIA=10.1 PACKET=40M
- TYPE=NO_BULK_SERVER MARIA=10.2 PACKET=40M
- COMPRESSION=false MARIA=10.2 PACKET=40M
- MYSQL=5.7 PACKET=8M
- MYSQL=5.7 PACKET=20M
- MYSQL=5.7 PACKET=40M
- MYSQL=5.6 PACKET=8M
- MYSQL=5.6 PACKET=20M
- MYSQL=5.6 PACKET=40M
script: .travis/script.sh
41 changes: 11 additions & 30 deletions .travis/before_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,59 +11,40 @@ remove_mysql(){
}
remove_mysql

case "$TYPE" in
"REWRITE" )
export URLSTRING=-DdbURL='jdbc:mariadb://localhost:3306/testj?user=root&rewriteBatchedStatements=true'
;;
"MULTI" )
export URLSTRING=-DdbURL='jdbc:mariadb://localhost:3306/testj?user=root&allowMultiQueries=true'
;;
"BULK_CLIENT" )
export URLSTRING=-DdbURL='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=true&useServerPrepStmts=false'
;;
"NO_BULK_CLIENT" )
export URLSTRING=-DdbURL='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false&useServerPrepStmts=false'
;;
"NO_BULK_SERVER" )
export URLSTRING=-DdbURL='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false'
;;
"COMPRESSION" )
export URLSTRING=-DdbURL='jdbc:mariadb://localhost:3306/testj?user=root&useCompression=true'
;;
esac;

if [ -n "$AURORA" ]
then
# AURORA tests doesn't need an installation
echo "$MYSQL_VERSION"
echo "$MYSQL"
else
if [ -n "$MYSQL_VERSION" ]
if [ -n "$MYSQL" ]
then
sudo tee /etc/apt/sources.list.d/mysql.list << END
deb http://repo.mysql.com/apt/ubuntu/ precise mysql-$MYSQL_VERSION
deb-src http://repo.mysql.com/apt/ubuntu/ precise mysql-$MYSQL_VERSION
deb http://repo.mysql.com/apt/ubuntu/ precise mysql-$MYSQL
deb-src http://repo.mysql.com/apt/ubuntu/ precise mysql-$MYSQL
END
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5072E1F5

sudo apt-get -qq update --force-yes
sudo apt-get -qq install mysql-server --force-yes

dpkg -l|grep ^ii|grep mysql-server|grep ${MYSQL_VERSION/-dmr/}
dpkg -l|grep ^ii|grep mysql-server|grep ${MYSQL/-dmr/}

else

sudo apt-get -qq install python-software-properties

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
sudo add-apt-repository "deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/${MARIA_VERSION}/ubuntu precise main"
sudo add-apt-repository "deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/${MARIA}/ubuntu precise main"

sudo apt-get -qq update

sudo apt-get -qq install mariadb-server
fi

INNODB_LOG_FILE_SIZE=$(echo $PACKET| cut -d'M' -f 1)0M
sudo tee /etc/mysql/conf.d/map.cnf << END
[mysqld]
max_allowed_packet=$MAX_ALLOWED_PACKET
max_allowed_packet=$PACKET
innodb_log_file_size=$INNODB_LOG_FILE_SIZE
END

Expand All @@ -84,15 +65,15 @@ END

sudo service mysql stop
#Adding sleep time for clean shutdown
if [ "x$MYSQL_VERSION" != "x" ]
if [ "x$MYSQL" != "x" ]
then
sleep 2
fi
sudo rm -f /var/lib/mysql/ib_logfile*
sudo service mysql start

#Adding sleep time if mysql DB. If not SSL not totally initialized when launching tests
if [ "x$MYSQL_VERSION" != "x" ]
if [ "x$MYSQL" != "x" ]
then
sleep 20
fi
Expand Down
35 changes: 35 additions & 0 deletions .travis/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

set -x
set -e

case "$TYPE" in
"REWRITE" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&rewriteBatchedStatements=true'
;;
"MULTI" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&allowMultiQueries=true'
;;
"BULK_CLIENT" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=true&useServerPrepStmts=false'
;;
"NO_BULK_CLIENT" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false&useServerPrepStmts=false'
;;
"NO_BULK_SERVER" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useBatchMultiSend=false'
;;
"COMPRESSION" )
urlString=-DdbUrl='jdbc:mariadb://localhost:3306/testj?user=root&useCompression=true'
;;
esac;

if [ -n "$AURORA" ]
then
testSingleHost=false
else
testSingleHost=true
fi


mvn clean test $urlString -DtestSingleHost=$testSingleHost $ADDITIONNAL_VARIABLES -DjobId=$TRAVIS_JOB_ID -DkeystorePath="/etc/mysql/client-keystore.p12" -DkeystorePassword="kspass"
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,10 @@ or maven :
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.4.6</version>
<version>1.5.2</version>
</dependency>
```

Current release candidate :

```script
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.5.0-RC1</version>
</dependency>
```


Development snapshot are available on sonatype nexus repository
```script
<repositories>
Expand Down
17 changes: 15 additions & 2 deletions documentation/changelog.creole
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
= Changelog
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#151|1.5.1]] RC released on 15-08-2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#150|1.5.0]] RC released on 28-07-2016
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#151|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
Expand All @@ -10,6 +11,18 @@
* [[https://github.com/MariaDB/mariadb-connector-j/documentation/changelog.creole#140|1.4.0]] Released on 31 march 2016
---
== 1.5.2
Release version
* CONJ-331 : clearWarnings() now throw exception on closed connection
* CONJ-299 : PreparedStatement.setObject(Type.BIT, "1") registered as true.
* CONJ-293 : permit named pipe connection without host
* CONJ-333 : ResultSet.getString() of PreparedStatement return NULL When TIME column value=00:00:00
RC corrections
* CONJ-335 : Pool connection may fail to connect with good user
* CONJ-332 : option enabledSslCipherSuites rely on java supportedCipherSuites (replacing enabledCipherSuites)
* UTF-8 conversion correction
== 1.5.1
Release candidate version
=== Evolution
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<artifactId>mariadb-java-client</artifactId>
<packaging>jar</packaging>
<name>mariadb-java-client</name>
<version>1.5.1-RC</version>
<version>1.5.2</version>
<description>JDBC driver for MariaDB and MySQL</description>
<url>https://mariadb.com/kb/en/mariadb/about-mariadb-connector-j/</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ private void setInternalObject(final int parameterIndex, final Object obj, final
try {
switch (targetSqlType) {
case Types.BIT:
setBoolean(parameterIndex, Boolean.valueOf(str));
case Types.BOOLEAN:
setBoolean(parameterIndex, !("false".equalsIgnoreCase(str) || "0".equals(str)));
break;
case Types.TINYINT:
setByte(parameterIndex, Byte.parseByte(str));
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/mariadb/jdbc/MariaDbClientPreparedStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
OF SUCH DAMAGE.
*/

import org.mariadb.jdbc.internal.logging.Logger;
import org.mariadb.jdbc.internal.logging.LoggerFactory;
import org.mariadb.jdbc.internal.packet.dao.parameters.ParameterHolder;
import org.mariadb.jdbc.internal.queryresults.*;
import org.mariadb.jdbc.internal.queryresults.resultset.MariaSelectResultSet;
Expand All @@ -62,6 +64,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS


public class MariaDbClientPreparedStatement extends AbstractMariaDbPrepareStatement implements Cloneable {
private static Logger logger = LoggerFactory.getLogger(MariaDbClientPreparedStatement.class);
private String sqlQuery;
private ClientPrepareResult prepareResult;
private ParameterHolder[] parameters;
Expand Down Expand Up @@ -206,6 +209,8 @@ protected boolean executeInternal() throws SQLException {
//valid parameters
for (int i = 0; i < prepareResult.getParamCount(); i++) {
if (parameters[i] == null) {
logger.error("You need to set exactly " + prepareResult.getParamCount()
+ " parameters on the prepared statement");
throw ExceptionMapper.getSqlException("You need to set exactly " + prepareResult.getParamCount()
+ " parameters on the prepared statement");
}
Expand Down Expand Up @@ -251,6 +256,8 @@ public void addBatch() throws SQLException {
for (int i = 0; i < holder.length; i++) {
holder[i] = parameters[i];
if (holder[i] == null) {
logger.error("You need to set exactly " + prepareResult.getParamCount()
+ " parameters on the prepared statement");
throw ExceptionMapper.getSqlException("You need to set exactly " + prepareResult.getParamCount()
+ " parameters on the prepared statement");
}
Expand Down Expand Up @@ -411,6 +418,9 @@ protected void setParameter(final int parameterIndex, final ParameterHolder hold
if (parameterIndex >= 1 && parameterIndex < prepareResult.getParamCount() + 1) {
parameters[parameterIndex - 1] = holder;
} else {
logger.error("Could not set parameter at position " + parameterIndex
+ " (values vas " + holder.toString() + ")");

throw ExceptionMapper.getSqlException("Could not set parameter at position " + parameterIndex
+ " (values vas " + holder.toString() + ")");
}
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/org/mariadb/jdbc/MariaDbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,21 @@ public PreparedStatement internalPrepareStatement(final String sql, final int re
checkConnection();

boolean canUsePrepareStatement = false;
if (options.rewriteBatchedStatements) {
//in case of CALL statement, handling INOUT parameter is better with Prepare protocol
String cleanSql = sql.toUpperCase().trim();
canUsePrepareStatement = cleanSql.contains("CALL");
} else if (options.useServerPrepStmts && sql != null) {

if (sql != null) {
String cleanSql = sql.toUpperCase().trim();
canUsePrepareStatement = (cleanSql.contains("SELECT")
|| cleanSql.contains("CALL")
|| cleanSql.contains("UPDATE")
|| cleanSql.contains("INSERT")
|| cleanSql.contains("DELETE")
|| cleanSql.contains("REPLACE")
|| cleanSql.contains("DO"));
if (!options.useServerPrepStmts) {
//in case of CALL statement, handling INOUT parameter is better with Prepare protocol
canUsePrepareStatement = cleanSql.contains("CALL");
} else if (options.useServerPrepStmts) {
canUsePrepareStatement = (cleanSql.contains("SELECT")
|| cleanSql.contains("CALL")
|| cleanSql.contains("UPDATE")
|| cleanSql.contains("INSERT")
|| cleanSql.contains("DELETE")
|| cleanSql.contains("REPLACE")
|| cleanSql.contains("DO"));
}
}

if (canUsePrepareStatement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
OF SUCH DAMAGE.
*/

import org.mariadb.jdbc.internal.logging.Logger;
import org.mariadb.jdbc.internal.logging.LoggerFactory;
import org.mariadb.jdbc.internal.packet.dao.parameters.ParameterHolder;
import org.mariadb.jdbc.internal.queryresults.ExecutionResult;
import org.mariadb.jdbc.internal.queryresults.MultiFixedIntExecutionResult;
Expand All @@ -62,6 +64,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import java.util.*;

public class MariaDbServerPreparedStatement extends AbstractMariaDbPrepareStatement implements Cloneable {
private static Logger logger = LoggerFactory.getLogger(MariaDbServerPreparedStatement.class);

String sql;
ServerPrepareResult serverPrepareResult = null;
Expand Down Expand Up @@ -125,6 +128,7 @@ private void prepare(String sql) throws SQLException {
} catch (Exception ee) {
//eat exception.
}
logger.error("error preparing query", e);
ExceptionMapper.throwException(e, connection, this);
}
}
Expand Down Expand Up @@ -323,6 +327,7 @@ protected void validParameters() throws SQLException {
if (serverPrepareResult != null) {
for (int i = 0; i < parameterCount; i++) {
if (currentParameterHolder.get(i) == null) {
logger.error("Parameter at position " + (i + 1) + " is not set");
ExceptionMapper.throwException(new QueryException("Parameter at position " + (i + 1) + " is not set", -1, "07004"),
connection, this);
}
Expand All @@ -332,6 +337,7 @@ protected void validParameters() throws SQLException {
for (int i = 0; i < parameterCount; i++) {
if (!currentParameterHolder.containsKey(i)) {
parameterCount = -1;
logger.error("Parameter at position " + (i + 1) + " is not set");
ExceptionMapper.throwException(new QueryException("Parameter at position " + (i + 1) + " is not set", -1, "07004"),
connection, this);
}
Expand Down
Loading

0 comments on commit 889863a

Please sign in to comment.