Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CONJ-1112] style correction after google style update
  • Loading branch information
rusher committed Oct 18, 2023
1 parent 141ed87 commit 2acd437
Show file tree
Hide file tree
Showing 84 changed files with 851 additions and 716 deletions.
26 changes: 13 additions & 13 deletions CHANGELOG.md
Expand Up @@ -87,9 +87,9 @@
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.1.0...3.1.1)

- 3.0.10 bug fix:
- CONJ-1023 Connector/J doesn't set SSL cap bit in Handshake Response Packet
- CONJ-1026 timezone=auto option failure on non-fixed-offset zone machine
- CONJ-1032 Compatibility for deprecated arguments is case sensitive now
- CONJ-1023 Connector/J doesn't set SSL cap bit in Handshake Response Packet
- CONJ-1026 timezone=auto option failure on non-fixed-offset zone machine
- CONJ-1032 Compatibility for deprecated arguments is case sensitive now
- CONJ-1036 org.mariadb.jdbc.client.socket.impl.PacketWriter.writeAscii() broken in 3.1.0

## [3.0.10](https://github.com/mariadb-corporation/mariadb-connector-j/tree/3.0.10) (Jan 2023)
Expand Down Expand Up @@ -144,7 +144,7 @@
##### Notable Changes

* small performance improvement
* [CONJ-1010] improve client side prepared parameter parameter substitution
* [CONJ-1010] improve client side prepared parameter parameter substitution

##### Bugs Fixed

Expand Down Expand Up @@ -250,7 +250,7 @@
[Full Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/compare/3.0.1-beta...3.0.2-rc)

* CONJ-879 Java 9 module full support
* Aws IAM credential now use sdk v2 authentication that support java 9 modularity
* Aws IAM credential now use sdk v2 authentication that support java 9 modularity
* CONJ-896 Ensure pool connections validation when a socket fail
* CONJ-897 Ensure having connection's thread id in Exception / debug logs

Expand Down Expand Up @@ -288,12 +288,12 @@ This version is a total rewrite of java driver.

* complete rewrite, code clarification, reduced size (15%), more than 90% coverage tested.
* Encoding/decoding implementation are now registred by Codec, permitting codec registry implementation
* example support of Geometry Object
* example support of Geometry Object
* Permit authentication plugin restriction by option `restrictedAuth`
* performance improvement:
* Prepare and execution are now using pipelining when using option `useServerPrepStmts`
* performance enhancement with MariaDB 10.6 server when using option `useServerPrepStmts`, skipping metadata (
see https://jira.mariadb.org/browse/MDEV-19237)
* Prepare and execution are now using pipelining when using option `useServerPrepStmts`
* performance enhancement with MariaDB 10.6 server when using option `useServerPrepStmts`, skipping metadata (
see https://jira.mariadb.org/browse/MDEV-19237)

correction:

Expand Down Expand Up @@ -1193,10 +1193,10 @@ Different performance improvement have been done :
up to 7% of query time, reduced to 3%.
* Better UTF-8 decoding avoiding memory consumption and gain 1-2% query time for big String.
* client parsing optimization : rewriteBatchedStatements (insert into ab (i) values (1) and insert into ab (i) values (
2) rewritten as insert into ab (i) values (1), (2))
is now 19% faster (Depending on queries 40-50% of CPU time was spend testing that buffer size is big enough to
contain
query).
2) rewritten as insert into ab (i) values (1), (2))
is now 19% faster (Depending on queries 40-50% of CPU time was spend testing that buffer size is big enough to
contain
query).
* there was some memory wastage when query return big resultset (> 10kb), slowing query.
* ...

Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -36,26 +36,26 @@ testj" and a user root without password.
so you can run

```script
mvn test
mvn test
```

You can change this parameter by adding -DdbUrl parameter. like :

```script
mvn test -DdbUrl=jdbc:mariadb://127.0.0.1:3306/testj?user=root&password=*****
mvn test -DdbUrl=jdbc:mariadb://127.0.0.1:3306/testj?user=root&password=*****
```

You can launch a specific test by adding -Dtest

```script
mvn test -Dtest=org.mariadb.jdbc.JdbcParserTest
mvn test -Dtest=org.mariadb.jdbc.JdbcParserTest
```

When all test are passing, you can package project.
Additional tests , like javadoc formatting, code style validation will be done :

```script
mvn package -Dmaven.test.skip=true
mvn package -Dmaven.test.skip=true
```

If operation succeed, a new mariadb-java-client jar will be on the target folder.
Expand Down
26 changes: 13 additions & 13 deletions README.md
@@ -1,7 +1,7 @@
<p style="text-align: center;">
<a href="https://mariadb.com/">
<img alt="mariadb logo" src="https://mariadb.com/kb/static/images/logo-2018-black.png">
</a>
<a href="https://mariadb.com/">
<img alt="mariadb logo" src="https://mariadb.com/kb/static/images/logo-2018-black.png">
</a>
</p>

# MariaDB java connector
Expand Down Expand Up @@ -37,19 +37,19 @@ Development snapshot are available on sonatype nexus repository

```script
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.2.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.2.1-SNAPSHOT</version>
</dependency>
</dependencies>
```

Expand Down
3 changes: 3 additions & 0 deletions licenseheader.txt
@@ -0,0 +1,3 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
// Copyright (c) 2012-2014 Monty Program Ab
// Copyright (c) 2015-2023 MariaDB Corporation Ab
18 changes: 11 additions & 7 deletions src/main/java/org/mariadb/jdbc/BasePreparedStatement.java
Expand Up @@ -214,7 +214,8 @@ public int executeUpdate(String sql) throws SQLException {
public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
throw exceptionFactory()
.create(
"executeUpdate(String sql, int autoGeneratedKeys) cannot be called on preparedStatement");
"executeUpdate(String sql, int autoGeneratedKeys) cannot be called on"
+ " preparedStatement");
}

@Override
Expand All @@ -228,7 +229,8 @@ public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
public int executeUpdate(String sql, String[] columnNames) throws SQLException {
throw exceptionFactory()
.create(
"executeUpdate(String sql, String[] columnNames) cannot be called on preparedStatement");
"executeUpdate(String sql, String[] columnNames) cannot be called on"
+ " preparedStatement");
}

@Override
Expand All @@ -241,21 +243,24 @@ public long executeLargeUpdate(String sql) throws SQLException {
public long executeLargeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
throw exceptionFactory()
.create(
"executeLargeUpdate(String sql, int autoGeneratedKeys) cannot be called on preparedStatement");
"executeLargeUpdate(String sql, int autoGeneratedKeys) cannot be called on"
+ " preparedStatement");
}

@Override
public long executeLargeUpdate(String sql, int[] columnIndexes) throws SQLException {
throw exceptionFactory()
.create(
"executeLargeUpdate(String sql, int[] columnIndexes) cannot be called on preparedStatement");
"executeLargeUpdate(String sql, int[] columnIndexes) cannot be called on"
+ " preparedStatement");
}

@Override
public long executeLargeUpdate(String sql, String[] columnNames) throws SQLException {
throw exceptionFactory()
.create(
"executeLargeUpdate(String sql, String[] columnNames) cannot be called on preparedStatement");
"executeLargeUpdate(String sql, String[] columnNames) cannot be called on"
+ " preparedStatement");
}

// ***************************************************************************************************
Expand Down Expand Up @@ -1187,8 +1192,7 @@ private void setInternalObject(
"HY000",
e);
}
} else if (obj instanceof Number) {
Number bd = (Number) obj;
} else if (obj instanceof Number bd) {
switch (targetSqlType) {
case Types.TINYINT:
setByte(parameterIndex, bd.byteValue());
Expand Down
53 changes: 29 additions & 24 deletions src/main/java/org/mariadb/jdbc/Connection.java
Expand Up @@ -58,6 +58,7 @@ public class Connection implements java.sql.Connection {
* @param lock thread safe locker
* @param client client object
*/
@SuppressWarnings({"this-escape"})
public Connection(Configuration conf, ReentrantLock lock, Client client) {
this.conf = conf;
this.forceTransactionEnd =
Expand Down Expand Up @@ -329,11 +330,12 @@ private String getDatabase() throws SQLException {
return client.getContext().getDatabase();
}

Statement stmt = createStatement();
ResultSet rs = stmt.executeQuery("select database()");
rs.next();
client.getContext().setDatabase(rs.getString(1));
return client.getContext().getDatabase();
try (Statement stmt = createStatement()) {
ResultSet rs = stmt.executeQuery("select database()");
rs.next();
client.getContext().setDatabase(rs.getString(1));
return client.getContext().getDatabase();
}
}

private void setDatabase(String database) throws SQLException {
Expand Down Expand Up @@ -371,29 +373,31 @@ public int getTransactionIsolation() throws SQLException {
}
}

ResultSet rs = createStatement().executeQuery(sql);
if (rs.next()) {
final String response = rs.getString(1);
switch (response) {
case "REPEATABLE-READ":
return java.sql.Connection.TRANSACTION_REPEATABLE_READ;
try (Statement stmt = createStatement()) {
ResultSet rs = stmt.executeQuery(sql);
if (rs.next()) {
final String response = rs.getString(1);
switch (response) {
case "REPEATABLE-READ":
return java.sql.Connection.TRANSACTION_REPEATABLE_READ;

case "READ-UNCOMMITTED":
return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
case "READ-UNCOMMITTED":
return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;

case "READ-COMMITTED":
return java.sql.Connection.TRANSACTION_READ_COMMITTED;
case "READ-COMMITTED":
return java.sql.Connection.TRANSACTION_READ_COMMITTED;

case "SERIALIZABLE":
return java.sql.Connection.TRANSACTION_SERIALIZABLE;
case "SERIALIZABLE":
return java.sql.Connection.TRANSACTION_SERIALIZABLE;

default:
throw exceptionFactory.create(
String.format(
"Could not get transaction isolation level: Invalid value \"%s\"", response));
default:
throw exceptionFactory.create(
String.format(
"Could not get transaction isolation level: Invalid value \"%s\"", response));
}
}
throw exceptionFactory.create("Failed to retrieve transaction isolation");
}
throw exceptionFactory.create("Failed to retrieve transaction isolation");
}

@Override
Expand Down Expand Up @@ -499,7 +503,8 @@ public CallableStatement prepareCall(String sql, int resultSetType, int resultSe
Matcher matcher = CALLABLE_STATEMENT_PATTERN.matcher(sql);
if (!matcher.matches()) {
throw new SQLSyntaxErrorException(
"invalid callable syntax. must be like {[?=]call <procedure/function name>[(?,?, ...)]}\n but was : "
"invalid callable syntax. must be like {[?=]call <procedure/function name>[(?,?, ...)]}\n"
+ " but was : "
+ sql);
}

Expand Down Expand Up @@ -927,7 +932,7 @@ public MariaDbSavepoint(final int savepointId) {
* @return the numeric ID of this savepoint
*/
public int getSavepointId() throws SQLException {
if (name != null) {
if (id == null) {
throw exceptionFactory.create("Cannot retrieve savepoint id of a named savepoint");
}
return id;
Expand Down

0 comments on commit 2acd437

Please sign in to comment.