Skip to content

Commit 5f9fda7

Browse files
committed
Merge branch 'release/next'
2 parents b07d136 + 0e20066 commit 5f9fda7

15 files changed

+155
-70
lines changed

Diff for: CHANGELOG.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to
55
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [4.10.1] - 2023-10-07
8+
### Changed
9+
- Update Apache Commons IO to version 2.14.0.
10+
- Harmonize logging.
11+
### Fixed
12+
- Fix multiple issues related to the method `findColumn(String)` of `CassandraResultSet` and `CassandraMetadataResultSet`:
13+
- Fix issue [#31](https://github.com/ing-bank/cassandra-jdbc-wrapper/issues/31) to return a 1-based index value.
14+
- Return a result even if there's no row in the result set but the column exist in the statement.
15+
- Fix the exception thrown by the method when the given column name does not exist in the result set (was an
16+
`IllegalArgumentException` instead of an `SQLException`.
17+
718
## [4.10.0] - 2023-09-30
819
### Added
920
- Add support for new [`vector` CQL type](https://datastax-oss.atlassian.net/browse/JAVA-3060)
10-
defined in [CEP-30](https://cwiki.apache.org/confluence/x/OQ40Dw)
21+
defined in [CEP-30](https://cwiki.apache.org/confluence/x/OQ40Dw).
1122
Also see PR [#27](https://github.com/ing-bank/cassandra-jdbc-wrapper/pull/27).
1223
- Implement the method `getWarnings()` in `CassandraResultSet`.
1324
- Implement the following methods of `CassandraDatabaseMetaData`:
@@ -151,6 +162,7 @@ For this version, the changelog lists the main changes comparatively to the late
151162
- Fix logs in `CassandraConnection` constructor.
152163

153164
[original project]: https://github.com/adejanovski/cassandra-jdbc-wrapper/
165+
[4.10.1]: https://github.com/ing-bank/cassandra-jdbc-wrapper/compare/v4.10.0...v4.10.1
154166
[4.10.0]: https://github.com/ing-bank/cassandra-jdbc-wrapper/compare/v4.9.1...v4.10.0
155167
[4.9.1]: https://github.com/ing-bank/cassandra-jdbc-wrapper/compare/v4.9.0...v4.9.1
156168
[4.9.0]: https://github.com/ing-bank/cassandra-jdbc-wrapper/compare/v4.8.0...v4.9.0

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ We use [SemVer](http://semver.org/) for versioning.
715715
* Marius Jokubauskas - **[@mjok](https://github.com/mjok)**
716716
* Sualeh Fatehi - **[@sualeh](https://github.com/sualeh)**
717717
* Cedrick Lunven - **[@clun](https://github.com/clun)**
718+
* Stefano Fornari - **[@stefanofornari](https://github.com/stefanofornari)**
718719

719720
And special thanks to the developer of the original project on which is based this one:
720721
* Alexander Dejanovski - **[@adejanovski](https://github.com/adejanovski)**

Diff for: pom.xml

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.ing.data</groupId>
77
<artifactId>cassandra-jdbc-wrapper</artifactId>
8-
<version>4.10.0</version>
8+
<version>4.10.1</version>
99
<packaging>jar</packaging>
1010

1111
<name>Cassandra JDBC Wrapper</name>
@@ -74,6 +74,13 @@
7474
<role>developer</role>
7575
</roles>
7676
</contributor>
77+
<contributor>
78+
<name>Stefano Fornari</name>
79+
<url>https://github.com/stefanofornari</url>
80+
<roles>
81+
<role>developer</role>
82+
</roles>
83+
</contributor>
7784
</contributors>
7885

7986
<scm>
@@ -101,7 +108,7 @@
101108
<checkstyle.version>9.3</checkstyle.version>
102109
<caffeine.version>2.9.3</caffeine.version>
103110
<commons-collections.version>4.4</commons-collections.version>
104-
<commons-io.version>2.13.0</commons-io.version>
111+
<commons-io.version>2.14.0</commons-io.version>
105112
<commons-lang3.version>3.13.0</commons-lang3.version>
106113
<datastax.java.driver.version>4.17.0</datastax.java.driver.version>
107114
<jackson.version>2.15.2</jackson.version>

Diff for: src/main/java/com/ing/data/cassandra/jdbc/CassandraMetadataResultSet.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ public void beforeFirst() throws SQLException {
226226

227227
private void checkIndex(final int index) throws SQLException {
228228
if (this.currentRow != null) {
229-
this.wasNull = this.currentRow.isNull(index - 1);
230229
if (this.currentRow.getColumnDefinitions() != null) {
231230
if (index < 1 || index > this.currentRow.getColumnDefinitions().asList().size()) {
232231
throw new SQLSyntaxErrorException(String.format(MUST_BE_POSITIVE, index) + StringUtils.SPACE
233232
+ this.currentRow.getColumnDefinitions().asList().size());
234233
}
235234
}
235+
this.wasNull = this.currentRow.isNull(index - 1);
236236
} else if (this.driverResultSet != null) {
237237
if (this.driverResultSet.getColumnDefinitions() != null) {
238238
if (index < 1 || index > this.driverResultSet.getColumnDefinitions().asList().size()) {
@@ -245,10 +245,10 @@ private void checkIndex(final int index) throws SQLException {
245245

246246
private void checkName(final String name) throws SQLException {
247247
if (this.currentRow != null) {
248-
this.wasNull = this.currentRow.isNull(name);
249248
if (!this.currentRow.getColumnDefinitions().contains(name)) {
250249
throw new SQLSyntaxErrorException(String.format(VALID_LABELS, name));
251250
}
251+
this.wasNull = this.currentRow.isNull(name);
252252
} else if (this.driverResultSet != null) {
253253
if (this.driverResultSet.getColumnDefinitions() != null) {
254254
if (!this.driverResultSet.getColumnDefinitions().contains(name)) {
@@ -282,7 +282,12 @@ public void close() throws SQLException {
282282
public int findColumn(final String columnLabel) throws SQLException {
283283
checkNotClosed();
284284
checkName(columnLabel);
285-
return this.currentRow.getColumnDefinitions().getIndexOf(columnLabel);
285+
if (this.currentRow != null) {
286+
return this.currentRow.getColumnDefinitions().getIndexOf(columnLabel) + 1;
287+
} else if (this.driverResultSet != null) {
288+
return this.driverResultSet.getColumnDefinitions().getIndexOf(columnLabel) + 1;
289+
}
290+
throw new SQLSyntaxErrorException(String.format(VALID_LABELS, columnLabel));
286291
}
287292

288293
@Override

Diff for: src/main/java/com/ing/data/cassandra/jdbc/CassandraPreparedStatement.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public void close() {
189189
try {
190190
this.connection.removeStatement(this);
191191
} catch (final Exception e) {
192-
LOG.warn("Unable to close the prepared statement: " + e.getMessage());
192+
LOG.warn("Unable to close the prepared statement: {}", e.getMessage());
193193
}
194194
}
195195

@@ -198,7 +198,7 @@ private void doExecute() throws SQLException {
198198
try {
199199
resetResults();
200200
if (LOG.isTraceEnabled() || this.connection.isDebugMode()) {
201-
LOG.trace("CQL: " + this.cql);
201+
LOG.trace("CQL: {}", this.cql);
202202
}
203203
// Force paging to avoid timeout and node harm.
204204
if (this.boundStatement.getPageSize() == 0) {
@@ -248,7 +248,7 @@ public int[] executeBatch() throws SQLException {
248248
try {
249249
final List<CompletionStage<AsyncResultSet>> futures = new ArrayList<>();
250250
if (LOG.isTraceEnabled() || this.connection.isDebugMode()) {
251-
LOG.trace("CQL statements: " + this.batchStatements.size());
251+
LOG.trace("CQL statements: {}", this.batchStatements.size());
252252
}
253253
for (final BoundStatement statement : this.batchStatements) {
254254
for (int i = 0; i < statement.getPreparedStatement().getVariableDefinitions().size(); i++) {
@@ -258,7 +258,7 @@ public int[] executeBatch() throws SQLException {
258258
}
259259
}
260260
if (LOG.isTraceEnabled() || this.connection.isDebugMode()) {
261-
LOG.trace("CQL: " + this.cql);
261+
LOG.trace("CQL: {}", this.cql);
262262
}
263263
final BoundStatement boundStatement = statement.setConsistencyLevel(
264264
this.connection.getDefaultConsistencyLevel());

Diff for: src/main/java/com/ing/data/cassandra/jdbc/CassandraResultSet.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,11 @@ public void beforeFirst() throws SQLException {
293293

294294
private void checkIndex(final int index) throws SQLException {
295295
if (this.currentRow != null) {
296-
this.wasNull = this.currentRow.isNull(index - 1);
297296
if (index < 1 || index > this.currentRow.getColumnDefinitions().size()) {
298297
throw new SQLSyntaxErrorException(String.format(MUST_BE_POSITIVE, index) + StringUtils.SPACE
299298
+ this.currentRow.getColumnDefinitions().size());
300299
}
300+
this.wasNull = this.currentRow.isNull(index - 1);
301301
} else if (this.driverResultSet != null) {
302302
if (index < 1 || index > this.driverResultSet.getColumnDefinitions().size()) {
303303
throw new SQLSyntaxErrorException(String.format(MUST_BE_POSITIVE, index) + StringUtils.SPACE
@@ -309,10 +309,10 @@ private void checkIndex(final int index) throws SQLException {
309309

310310
private void checkName(final String name) throws SQLException {
311311
if (this.currentRow != null) {
312-
this.wasNull = this.currentRow.isNull(name);
313312
if (!this.currentRow.getColumnDefinitions().contains(name)) {
314313
throw new SQLSyntaxErrorException(String.format(VALID_LABELS, name));
315314
}
315+
this.wasNull = this.currentRow.isNull(name);
316316
} else if (this.driverResultSet != null) {
317317
if (!this.driverResultSet.getColumnDefinitions().contains(name)) {
318318
throw new SQLSyntaxErrorException(String.format(VALID_LABELS, name));
@@ -344,7 +344,12 @@ public void close() throws SQLException {
344344
public int findColumn(final String columnLabel) throws SQLException {
345345
checkNotClosed();
346346
checkName(columnLabel);
347-
return this.currentRow.getColumnDefinitions().firstIndexOf(columnLabel);
347+
if (this.currentRow != null) {
348+
return this.currentRow.getColumnDefinitions().firstIndexOf(columnLabel) + 1;
349+
} else if (this.driverResultSet != null) {
350+
return this.driverResultSet.getColumnDefinitions().firstIndexOf(columnLabel) + 1;
351+
}
352+
throw new SQLSyntaxErrorException(String.format(VALID_LABELS, columnLabel));
348353
}
349354

350355
@Override
@@ -1025,7 +1030,7 @@ public Object getObject(final String columnLabel) throws SQLException {
10251030
@Override
10261031
public <T> T getObject(final String columnLabel, final Class<T> type) throws SQLException {
10271032
final int index = findColumn(columnLabel);
1028-
return getObject(index + 1, type);
1033+
return getObject(index, type);
10291034
}
10301035

10311036
@Override
@@ -1149,7 +1154,7 @@ public <T> T getObjectFromJson(final int columnIndex, final Class<T> type) throw
11491154
@Override
11501155
public <T> T getObjectFromJson(final String columnLabel, final Class<T> type) throws SQLException {
11511156
final int index = findColumn(columnLabel);
1152-
return getObjectFromJson(index + 1, type);
1157+
return getObjectFromJson(index, type);
11531158
}
11541159

11551160
@Override

Diff for: src/main/java/com/ing/data/cassandra/jdbc/CassandraStatement.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private void doExecute(final String cql) throws SQLException {
370370

371371
private com.datastax.oss.driver.api.core.cql.ResultSet executeSingleStatement(final String cql) {
372372
if (LOG.isTraceEnabled() || this.connection.isDebugMode()) {
373-
LOG.debug("CQL: " + cql);
373+
LOG.debug("CQL: {}", cql);
374374
}
375375
SimpleStatement stmt = SimpleStatement.newInstance(cql)
376376
.setConsistencyLevel(this.connection.getDefaultConsistencyLevel())
@@ -407,12 +407,12 @@ public int[] executeBatch() throws SQLException {
407407
final int[] returnCounts = new int[this.batchQueries.size()];
408408
final List<CompletionStage<AsyncResultSet>> futures = new ArrayList<>();
409409
if (LOG.isTraceEnabled() || this.connection.isDebugMode()) {
410-
LOG.debug("CQL statements: " + this.batchQueries.size());
410+
LOG.debug("CQL statements: {}", this.batchQueries.size());
411411
}
412412

413413
for (final String query : this.batchQueries) {
414414
if (LOG.isTraceEnabled() || this.connection.isDebugMode()) {
415-
LOG.debug("CQL: " + query);
415+
LOG.debug("CQL: {}", query);
416416
}
417417
SimpleStatement stmt = SimpleStatement.newInstance(query)
418418
.setConsistencyLevel(this.connection.getDefaultConsistencyLevel());

Diff for: src/test/java/com/ing/data/cassandra/jdbc/ConnectionUnitTest.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
import static org.mockito.Mockito.when;
7878

7979
class ConnectionUnitTest extends UsingCassandraContainerTest {
80-
private static final Logger log = LoggerFactory.getLogger(ConnectionUnitTest.class);
80+
private static final Logger LOG = LoggerFactory.getLogger(ConnectionUnitTest.class);
8181

8282
private static final String KEYSPACE = "system";
8383

@@ -427,15 +427,15 @@ void givenConnection_whenGetMetaData_getExpectedResultSet() throws Exception {
427427
assertNotNull(sqlConnection.getMetaData());
428428

429429
final DatabaseMetaData dbMetadata = sqlConnection.getMetaData();
430-
log.debug("====================================================");
431-
log.debug("Connection Metadata");
432-
log.debug("====================================================");
433-
log.debug("Driver name: {}", dbMetadata.getDriverName());
434-
log.debug("Driver version: {}", dbMetadata.getDriverVersion());
435-
log.debug("DB name: {}", dbMetadata.getDatabaseProductName());
436-
log.debug("DB version: {}", dbMetadata.getDatabaseProductVersion());
437-
log.debug("JDBC version: {}.{}", dbMetadata.getJDBCMajorVersion(), dbMetadata.getJDBCMinorVersion());
438-
log.debug("====================================================");
430+
LOG.debug("====================================================");
431+
LOG.debug("Connection Metadata");
432+
LOG.debug("====================================================");
433+
LOG.debug("Driver name: {}", dbMetadata.getDriverName());
434+
LOG.debug("Driver version: {}", dbMetadata.getDriverVersion());
435+
LOG.debug("DB name: {}", dbMetadata.getDatabaseProductName());
436+
LOG.debug("DB version: {}", dbMetadata.getDatabaseProductVersion());
437+
LOG.debug("JDBC version: {}.{}", dbMetadata.getJDBCMajorVersion(), dbMetadata.getJDBCMinorVersion());
438+
LOG.debug("====================================================");
439439

440440
assertEquals("Cassandra JDBC Driver", dbMetadata.getDriverName());
441441
assertNotEquals(0, dbMetadata.getDriverMajorVersion());

Diff for: src/test/java/com/ing/data/cassandra/jdbc/DbaasAstraIntegrationTest.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
@TestMethodOrder(org.junit.jupiter.api.MethodOrderer.OrderAnnotation.class)
4141
class DbaasAstraIntegrationTest {
4242

43-
private static final Logger log = LoggerFactory.getLogger(DbaasAstraIntegrationTest.class);
43+
private static final Logger LOG = LoggerFactory.getLogger(DbaasAstraIntegrationTest.class);
4444
private static final String ASTRA_DB_TOKEN_ENV_VARIABLE = "ASTRA_DB_APPLICATION_TOKEN";
4545
private static final String ASTRA_DB_TOKEN_PATTERN = "Astra.*";
4646
private static final String DATABASE_NAME = "test_cassandra_jdbc";
@@ -51,13 +51,13 @@ class DbaasAstraIntegrationTest {
5151
@BeforeAll
5252
static void setupAstra() throws Exception {
5353
if (System.getenv(ASTRA_DB_TOKEN_ENV_VARIABLE) != null) {
54-
log.debug("ASTRA_DB_APPLICATION_TOKEN is provided, AstraDB tests are executed.");
54+
LOG.debug("ASTRA_DB_APPLICATION_TOKEN is provided, AstraDB tests are executed.");
5555

5656
/*
5757
* Devops API Client (create database, resume, delete)
5858
*/
5959
final AstraDbClient astraDbClient = new AstraDbClient(TestUtils.getAstraToken());
60-
log.debug("Connected the DBaaS API.");
60+
LOG.debug("Connected the DBaaS API.");
6161

6262
/*
6363
* Set up a Database in Astra: create if not exist, resume if needed.
@@ -67,7 +67,7 @@ static void setupAstra() throws Exception {
6767
String dbId = TestUtils.setupVectorDatabase(DATABASE_NAME, KEYSPACE_NAME);
6868
Assertions.assertTrue(astraDbClient.findById(dbId).isPresent());
6969
Assertions.assertEquals(DatabaseStatusType.ACTIVE, astraDbClient.findById(dbId).get().getStatus());
70-
log.debug("Database ready.");
70+
LOG.debug("Database ready.");
7171

7272
/*
7373
* Download cloud secure bundle to connect to the database.
@@ -77,7 +77,7 @@ static void setupAstra() throws Exception {
7777
astraDbClient
7878
.database(dbId)
7979
.downloadDefaultSecureConnectBundle("/tmp/" + DATABASE_NAME + "_scb.zip");
80-
log.debug("Connection bundle downloaded.");
80+
LOG.debug("Connection bundle downloaded.");
8181

8282
/*
8383
* Building jdbcUrl and sqlConnection.
@@ -90,7 +90,7 @@ static void setupAstra() throws Exception {
9090
"&consistency=" + "LOCAL_QUORUM" +
9191
"&secureconnectbundle=/tmp/" + DATABASE_NAME + "_scb.zip");
9292
} else {
93-
log.debug("ASTRA_DB_APPLICATION_TOKEN is not defined, skipping AstraDB tests.");
93+
LOG.debug("ASTRA_DB_APPLICATION_TOKEN is not defined, skipping AstraDB tests.");
9494
}
9595
}
9696

Diff for: src/test/java/com/ing/data/cassandra/jdbc/JdbcRegressionUnitTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
* <a href="https://github.com/adejanovski/cassandra-jdbc-wrapper/">original project from GitHub</a>.
6666
*/
6767
class JdbcRegressionUnitTest extends UsingCassandraContainerTest {
68-
private static final Logger log = LoggerFactory.getLogger(JdbcRegressionUnitTest.class);
6968

7069
private static final String KEYSPACE = "test_keyspace3";
7170
private static final String TABLE = "regressions_test";

0 commit comments

Comments
 (0)