diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..b10554f --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,44 @@ +# This workflow builds and pushes the Docker image for the OJP server. +name: OJP Server Docker Image Build + +on: + workflow_dispatch: + inputs: + tag: + description: 'Docker image tag' + required: true + default: 'latest' + repository: + description: 'Repository name' + required: true + default: 'rrobetti' +jobs: + build-docker-image: + name: Build Docker Image + runs-on: ubuntu-latest + + steps: + - name: Git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 22 + uses: actions/setup-java@v4 + with: + java-version: 22 + distribution: 'temurin' + cache: maven + + - name: Build and push Docker image + env: + DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + DOCKERHUB_REPO: ${{ github.event.inputs.repository }} + run: | + mvn compile jib:build -pl ojp-server \ + -Djib.to.auth.username="${DOCKERHUB_USER}" \ + -Djib.to.auth.password="${DOCKERHUB_TOKEN}" \ + -Djib.to.image="${DOCKERHUB_REPO}/ojp:${{ github.event.inputs.tag }}" \ + -Djib.container.mainClass="org.openjdbcproxy.grpc.server.GrpcServer" \ + -Djib.container.ports=1059 \ No newline at end of file diff --git a/.github/workflows/main-docker.yml b/.github/workflows/main-docker.yml new file mode 100644 index 0000000..b804b6c --- /dev/null +++ b/.github/workflows/main-docker.yml @@ -0,0 +1,44 @@ +# This workflow builds and pushes the Docker image for the OJP server. +# It should only trigger when there are changes in the `ojp-server` or `ojp-grpc-commons` modules. +name: Main OJP Server Docker Image CI + +on: + push: + branches: [ main ] + paths: + - '.github/workflows/main-docker.yml' + - 'ojp-server/**' + - 'ojp-grpc-commons/**' + +jobs: + build-docker-image: + name: Build Docker Image + runs-on: ubuntu-latest + if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" + + steps: + - name: Git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 22 + uses: actions/setup-java@v4 + with: + java-version: 22 + distribution: 'temurin' + cache: maven + + - name: Build and push Docker image + env: + DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + DOCKERHUB_REPO: ${{ vars.DOCKERHUB_REPO }} + run: | + mvn compile jib:build -pl ojp-server \ + -Dimage="${DOCKERHUB_REPO}:latest" \ + -Djib.to.auth.username="${DOCKERHUB_USER}" \ + -Djib.to.auth.password="${DOCKERHUB_TOKEN}" \ + -Djib.to.image="${DOCKERHUB_REPO}/ojp:latest" \ + -Djib.container.mainClass="org.openjdbcproxy.grpc.server.GrpcServer" \ + -Djib.container.ports=1059 \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0a9a371..76b4063 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,10 @@ jobs: name: Build & Test runs-on: ubuntu-latest if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" + strategy: + fail-fast: false + matrix: + java-version: [ 11, 17, 21, 22 ] services: postgres: @@ -36,18 +40,34 @@ jobs: with: fetch-depth: 0 - - name: Set up JDK 22 + - name: Set up JDK 22 for ojp-server uses: actions/setup-java@v4 with: java-version: 22 distribution: 'temurin' cache: maven - - name: Build + - name: Build (ojp-server) run: mvn clean install -DskipTests - - name: Run ojp-server + - name: Test (ojp-server) + run: mvn test -pl ojp-server + + - name: Run (ojp-server) run: mvn verify -pl ojp-server -Prun-ojp-server > ojp-server.log 2>&1 & - - name: Run tests - run: mvn test \ No newline at end of file + - name: Wait for ojp-server to start + run: sleep 10 + + - name: Set up JDK ${{ matrix.java-version }} for ojp-grpc-commons and ojp-jdbc-driver + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + cache: maven + + - name: Build (ojp-grpc-commons, ojp-jdbc-driver) + run: mvn clean install -pl ojp-grpc-commons,ojp-jdbc-driver -DskipTests + + - name: Test (ojp-grpc-commons, ojp-jdbc-driver) + run: mvn test -pl ojp-grpc-commons,ojp-jdbc-driver \ No newline at end of file diff --git a/ojp-grpc-commons/pom.xml b/ojp-grpc-commons/pom.xml index 9130642..5a1a4a8 100644 --- a/ojp-grpc-commons/pom.xml +++ b/ojp-grpc-commons/pom.xml @@ -15,6 +15,9 @@ + 11 + 11 + 1.73.0 1.7.1 1.18.38 diff --git a/ojp-jdbc-driver/dependency-reduced-pom.xml b/ojp-jdbc-driver/dependency-reduced-pom.xml new file mode 100644 index 0000000..470ee2a --- /dev/null +++ b/ojp-jdbc-driver/dependency-reduced-pom.xml @@ -0,0 +1,104 @@ + + + + ojp-parent + org.openjdbcproxy + 1.0-SNAPSHOT + + 4.0.0 + ojp-jdbc-driver + 1.0-SNAPSHOT + + + + maven-surefire-plugin + 3.2.5 + + alphabetical + + + + maven-shade-plugin + 3.5.1 + + + package + + shade + + + true + + + + + + + + + + + + + org.projectlombok + lombok + 1.18.38 + provided + + + junit + junit + 4.13.2 + test + + + hamcrest-core + org.hamcrest + + + + + com.h2database + h2 + 2.3.232 + test + + + org.junit.jupiter + junit-jupiter + 5.12.1 + test + + + junit-jupiter-api + org.junit.jupiter + + + junit-jupiter-engine + org.junit.jupiter + + + + + org.junit.jupiter + junit-jupiter-params + 5.12.1 + test + + + apiguardian-api + org.apiguardian + + + junit-jupiter-api + org.junit.jupiter + + + + + + 11 + 2.0.17 + 11 + + diff --git a/ojp-jdbc-driver/pom.xml b/ojp-jdbc-driver/pom.xml index cc17b62..afcb7ce 100644 --- a/ojp-jdbc-driver/pom.xml +++ b/ojp-jdbc-driver/pom.xml @@ -15,6 +15,9 @@ + 11 + 11 + 2.0.17 diff --git a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/grpc/client/StatementServiceGrpcClient.java b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/grpc/client/StatementServiceGrpcClient.java index 6d03426..5701aed 100644 --- a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/grpc/client/StatementServiceGrpcClient.java +++ b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/grpc/client/StatementServiceGrpcClient.java @@ -204,8 +204,9 @@ public void onNext(LobReference lobReference) { @Override public void onError(Throwable throwable) { - if (throwable instanceof StatusRuntimeException sre) { + if (throwable instanceof StatusRuntimeException) { try { + StatusRuntimeException sre = (StatusRuntimeException) throwable; handle(sre);//To convert to SQLException if possible sfFirstLobReference.setException(sre); sfFinalLobReference.setException(sre); //When conversion to SQLException not possible @@ -334,8 +335,8 @@ public void onCompleted() { //Wait to receive at least one successful block before returning. if (!sfFirstBlockReceived.get() && errorReceived[0] != null) { - if (errorReceived[0] instanceof Exception e) { - throw e; + if (errorReceived[0] instanceof Exception) { + throw (Exception) errorReceived[0]; } else { throw new RuntimeException(errorReceived[0]); } @@ -401,9 +402,9 @@ public void onNext(SessionTerminationStatus sessionTerminationStatus) { @Override public void onError(Throwable throwable) { Throwable t = throwable; - if (throwable instanceof StatusRuntimeException sre) { + if (throwable instanceof StatusRuntimeException) { try { - handle(sre); + handle((StatusRuntimeException) throwable); } catch (SQLException e) { t = e; } diff --git a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/LobGrpcIterator.java b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/LobGrpcIterator.java index e1b9cf6..98e15b6 100644 --- a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/LobGrpcIterator.java +++ b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/LobGrpcIterator.java @@ -46,8 +46,8 @@ public LobDataBlock next() { if (this.error != null) { throw new RuntimeException(this.error); } - LobDataBlock block = this.blocksReceived.getFirst(); - this.blocksReceived.removeFirst(); + LobDataBlock block = this.blocksReceived.get(0); + this.blocksReceived.remove(0); return block; } diff --git a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/PreparedStatement.java b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/PreparedStatement.java index 67cbbb9..263ffb0 100644 --- a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/PreparedStatement.java +++ b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/PreparedStatement.java @@ -37,6 +37,7 @@ import java.sql.Time; import java.sql.Timestamp; import java.util.Arrays; +import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; import java.util.Iterator; @@ -108,7 +109,7 @@ public ResultSet executeQuery() throws SQLException { this.checkClosed(); log.info("Executing query for -> {}", this.sql); Iterator itOpResult = this.statementService - .executeQuery(this.connection.getSession(), this.sql, this.paramsMap.values().stream().toList(), this.properties); + .executeQuery(this.connection.getSession(), this.sql, new ArrayList<>(this.paramsMap.values()), this.properties); return new ResultSet(itOpResult, this.statementService, this); } @@ -117,7 +118,7 @@ public int executeUpdate() throws SQLException { this.checkClosed(); log.info("Executing update for -> {}", this.sql); OpResult result = this.statementService.executeUpdate(this.connection.getSession(), this.sql, - this.paramsMap.values().stream().toList(), this.getStatementUUID(), null); + new ArrayList<>(this.paramsMap.values()), this.getStatementUUID(), null); this.connection.setSession(result.getSession()); return deserialize(result.getValue().toByteArray(), Integer.class); } @@ -129,7 +130,7 @@ public void addBatch() throws SQLException { Map properties = new HashMap<>(); properties.put(CommonConstants.PREPARED_STATEMENT_ADD_BATCH_FLAG, Boolean.TRUE); OpResult result = this.statementService.executeUpdate(this.connection.getSession(), this.sql, - this.paramsMap.values().stream().toList(), this.getStatementUUID(), properties); + new ArrayList<>(this.paramsMap.values()), this.getStatementUUID(), properties); this.connection.setSession(result.getSession()); if (StringUtils.isBlank(this.getStatementUUID()) && ResultType.UUID_STRING.equals(result.getType()) && !result.getValue().isEmpty()) { @@ -752,7 +753,7 @@ private T callProxy(CallType callType, String targetName, Class returnTyp ); CallResourceResponse response = this.statementService.callResource(reqBuilder.build()); this.connection.setSession(response.getSession()); - if (this.getStatementUUID() == null && !response.getResourceUUID().isBlank()) { + if (this.getStatementUUID() == null && StringUtils.isNotBlank(response.getResourceUUID())) { this.setStatementUUID(response.getResourceUUID()); } if (Void.class.equals(returnType)) { diff --git a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSet.java b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSet.java index c571e93..a5fca47 100644 --- a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSet.java +++ b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSet.java @@ -162,7 +162,8 @@ public int getInt(int columnIndex) throws SQLException { } lastValueRead = currentDataBlock.get(blockIdx.get())[columnIndex - 1]; Object value = lastValueRead; - if (value instanceof Long lValue) { + if (value instanceof Long) { + Long lValue = (Long) value; return lValue.intValue(); } else { return (int) value; @@ -185,7 +186,8 @@ public float getFloat(int columnIndex) throws SQLException { } lastValueRead = currentDataBlock.get(blockIdx.get())[columnIndex -1]; Object value = lastValueRead; - if (value instanceof BigDecimal bdValue) { + if (value instanceof BigDecimal) { + BigDecimal bdValue = (BigDecimal) value; return bdValue.floatValue(); } return (float) value; @@ -198,7 +200,8 @@ public double getDouble(int columnIndex) throws SQLException { } lastValueRead = currentDataBlock.get(blockIdx.get())[columnIndex -1]; Object value = lastValueRead; - if (value instanceof BigDecimal bdValue) { + if (value instanceof BigDecimal) { + BigDecimal bdValue = (BigDecimal) value; return bdValue.doubleValue(); } return (double) value; @@ -229,7 +232,8 @@ public Date getDate(int columnIndex) throws SQLException { } lastValueRead = currentDataBlock.get(blockIdx.get())[columnIndex -1]; Object result = lastValueRead; - if (result instanceof Timestamp timestamp) { + if (result instanceof Timestamp) { + Timestamp timestamp = (Timestamp) result; return new Date(timestamp.getTime()); } return (Date) result; @@ -335,7 +339,8 @@ public int getInt(String columnLabel) throws SQLException { int colIdx = this.labelsMap.get(columnLabel.toUpperCase()) + 1; lastValueRead = currentDataBlock.get(blockIdx.get())[colIdx - 1]; Object value = lastValueRead; - if (value instanceof Long lValue) { + if (value instanceof Long) { + Long lValue = (Long) value; return lValue.intValue(); } else { return (int) value; @@ -360,7 +365,8 @@ public float getFloat(String columnLabel) throws SQLException { int colIdx = this.labelsMap.get(columnLabel.toUpperCase()) + 1; lastValueRead = currentDataBlock.get(blockIdx.get())[colIdx - 1]; Object value = lastValueRead; - if (value instanceof BigDecimal bdValue) { + if (value instanceof BigDecimal) { + BigDecimal bdValue = (BigDecimal) value; return bdValue.floatValue(); } return (float) value; @@ -374,7 +380,8 @@ public double getDouble(String columnLabel) throws SQLException { int colIdx = this.labelsMap.get(columnLabel.toUpperCase()) + 1; lastValueRead = currentDataBlock.get(blockIdx.get())[colIdx - 1]; Object value = lastValueRead; - if (value instanceof BigDecimal bdValue) { + if (value instanceof BigDecimal) { + BigDecimal bdValue = (BigDecimal) value; return bdValue.doubleValue(); } return (double) value; @@ -406,7 +413,8 @@ public Date getDate(String columnLabel) throws SQLException { int colIdx = this.labelsMap.get(columnLabel.toUpperCase()) + 1; lastValueRead = currentDataBlock.get(blockIdx.get())[colIdx - 1]; Object result = lastValueRead; - if (result instanceof Timestamp timestamp) { + if (result instanceof Timestamp) { + Timestamp timestamp = (Timestamp) result; return new Date(timestamp.getTime()); } return (Date) result; diff --git a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSetMetaData.java b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSetMetaData.java index 65a5f81..e8bdca4 100644 --- a/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSetMetaData.java +++ b/ojp-jdbc-driver/src/main/java/org/openjdbcproxy/jdbc/ResultSetMetaData.java @@ -35,7 +35,8 @@ public ResultSetMetaData(PreparedStatement ps, StatementService statementService @Override public int getColumnCount() throws SQLException { - if (resultSet instanceof org.openjdbcproxy.jdbc.ResultSet rs) { + if (resultSet instanceof org.openjdbcproxy.jdbc.ResultSet) { + org.openjdbcproxy.jdbc.ResultSet rs = (org.openjdbcproxy.jdbc.ResultSet) resultSet; return rs.getLabelsMap().size(); } else { return this.retrieveMetadataAttribute(CallType.CALL_GET, "ColumnCount",-1, Integer.class); diff --git a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BasicCrudIntegrationTest.java b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BasicCrudIntegrationTest.java index 84c0017..ce8b9b4 100644 --- a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BasicCrudIntegrationTest.java +++ b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BasicCrudIntegrationTest.java @@ -34,21 +34,17 @@ public void crudTestSuccessful(String driverClass, String url, String user, Stri System.out.println("Testing for url -> " + url); try { - executeUpdate(conn, """ - drop table test_table - """); + executeUpdate(conn, "drop table test_table"); } catch (Exception e) { //Does not matter } - executeUpdate(conn, """ - create table test_table( - id INT NOT NULL, - title VARCHAR(50) NOT NULL) - """); - executeUpdate(conn, """ - insert into test_table (id, title) values (1, 'TITLE_1') - """); + executeUpdate(conn, "create table test_table(" + + "id INT NOT NULL," + + "title VARCHAR(50) NOT NULL" + + ")"); + + executeUpdate(conn, " insert into test_table (id, title) values (1, 'TITLE_1')"); java.sql.PreparedStatement psSelect = conn.prepareStatement("select * from test_table where id = ?"); psSelect.setInt(1, 1); @@ -59,9 +55,7 @@ insert into test_table (id, title) values (1, 'TITLE_1') Assert.assertEquals(1, id); Assert.assertEquals("TITLE_1", title); - executeUpdate(conn, """ - update test_table set title='TITLE_1_UPDATED' - """); + executeUpdate(conn, "update test_table set title='TITLE_1_UPDATED'"); ResultSet resultSetUpdated = psSelect.executeQuery(); resultSetUpdated.next(); @@ -70,9 +64,7 @@ insert into test_table (id, title) values (1, 'TITLE_1') Assert.assertEquals(1, idUpdated); Assert.assertEquals("TITLE_1_UPDATED", titleUpdated); - executeUpdate(conn, """ - delete from test_table where id=1 and title='TITLE_1_UPDATED' - """); + executeUpdate(conn, " delete from test_table where id=1 and title='TITLE_1_UPDATED'"); ResultSet resultSetAfterDeletion = psSelect.executeQuery(); Assert.assertFalse(resultSetAfterDeletion.next()); diff --git a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BinaryStreamIntegrationTest.java b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BinaryStreamIntegrationTest.java index b9dca95..30a5621 100644 --- a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BinaryStreamIntegrationTest.java +++ b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BinaryStreamIntegrationTest.java @@ -36,28 +36,22 @@ public void createAndReadingBinaryStreamSuccessful(String driverClass, String ur System.out.println("Testing for url -> " + url); try { - executeUpdate(conn, - """ - drop table test_table_blob - """); + executeUpdate(conn, "drop table test_table_blob"); } catch (Exception e) { //If fails disregard as per the table is most possibly not created yet } executeUpdate(conn, - """ - create table test_table_blob( - val_blob1 BYTEA, - val_blob2 BYTEA - ) - """); + "create table test_table_blob(" + + " val_blob1 BYTEA," + + " val_blob2 BYTEA" + + ")" + ); conn.setAutoCommit(false); PreparedStatement psInsert = conn.prepareStatement( - """ - insert into test_table_blob (val_blob1, val_blob2) values (?, ?) - """ + "insert into test_table_blob (val_blob1, val_blob2) values (?, ?)" ); String testString = "BLOB VIA INPUT STREAM"; @@ -86,10 +80,7 @@ insert into test_table_blob (val_blob1, val_blob2) values (?, ?) String fromBlobByIdx2 = new String(blobResult2.readAllBytes()); Assert.assertEquals(testString.substring(0, 5), fromBlobByIdx2); - executeUpdate(conn, - """ - delete from test_table_blob - """ + executeUpdate(conn, "delete from test_table_blob" ); resultSet.close(); @@ -107,25 +98,19 @@ public void createAndReadingLargeBinaryStreamSuccessful(String driverClass, Stri System.out.println("Testing for url -> " + url); try { - executeUpdate(conn, - """ - drop table test_table_blob - """); + executeUpdate(conn, "drop table test_table_blob"); } catch (Exception e) { //If fails disregard as per the table is most possibly not created yet } executeUpdate(conn, - """ - create table test_table_blob( - val_blob BYTEA - ) - """); + "create table test_table_blob(" + + " val_blob BYTEA" + + ")" + ); PreparedStatement psInsert = conn.prepareStatement( - """ - insert into test_table_blob (val_blob) values (?) - """ + "insert into test_table_blob (val_blob) values (?)" ); @@ -150,11 +135,7 @@ insert into test_table_blob (val_blob) values (?) byteFile = inputStreamTestFile.read(); } - executeUpdate(conn, - """ - delete from test_table_blob - """ - ); + executeUpdate(conn, "delete from test_table_blob"); resultSet.close(); psSelect.close(); diff --git a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BlobIntegrationTest.java b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BlobIntegrationTest.java index 292d58b..691e3eb 100644 --- a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BlobIntegrationTest.java +++ b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/BlobIntegrationTest.java @@ -26,27 +26,21 @@ public void createAndReadingBLOBsSuccessful(String driverClass, String url, Stri System.out.println("Testing for url -> " + url); try { - executeUpdate(conn, - """ - drop table test_table_blob - """); + executeUpdate(conn, "drop table test_table_blob"); } catch (Exception e) { //If fails disregard as per the table is most possibly not created yet } executeUpdate(conn, - """ - create table test_table_blob( - val_blob BLOB, - val_blob2 BLOB, - val_blob3 BLOB - ) - """); + "create table test_table_blob(" + + " val_blob BLOB," + + " val_blob2 BLOB," + + " val_blob3 BLOB" + + ")" + ); PreparedStatement psInsert = conn.prepareStatement( - """ - insert into test_table_blob (val_blob, val_blob2, val_blob3) values (?, ?, ?) - """ + " insert into test_table_blob (val_blob, val_blob2, val_blob3) values (?, ?, ?)" ); String testString = "TEST STRING BLOB"; @@ -81,11 +75,7 @@ insert into test_table_blob (val_blob, val_blob2, val_blob3) values (?, ?, ?) String fromBlobByIdx3 = new String(blobResult3.getBinaryStream().readAllBytes()); Assert.assertEquals(testString2.substring(0, 5), fromBlobByIdx3); - executeUpdate(conn, - """ - delete from test_table_blob - """ - ); + executeUpdate(conn, "delete from test_table_blob"); resultSet.close(); psSelect.close(); @@ -100,25 +90,19 @@ public void creatingAndReadingLargeBLOBsSuccessful(String driverClass, String ur System.out.println("Testing for url -> " + url); try { - executeUpdate(conn, - """ - drop table test_table_blob - """); + executeUpdate(conn, "drop table test_table_blob"); } catch (Exception e) { //If fails disregard as per the table is most possibly not created yet } executeUpdate(conn, - """ - create table test_table_blob( - val_blob BLOB - ) - """); + "create table test_table_blob(" + + " val_blob BLOB" + + ")" + ); PreparedStatement psInsert = conn.prepareStatement( - """ - insert into test_table_blob (val_blob) values (?) - """ + "insert into test_table_blob (val_blob) values (?)" ); @@ -152,11 +136,7 @@ insert into test_table_blob (val_blob) values (?) byteFile = inputStreamTestFile.read(); } - executeUpdate(conn, - """ - delete from test_table_blob - """ - ); + executeUpdate(conn, "delete from test_table_blob"); resultSet.close(); psSelect.close(); diff --git a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/H2MultipleTypesIntegrationTest.java b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/H2MultipleTypesIntegrationTest.java index bf9fe1f..fa883c4 100644 --- a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/H2MultipleTypesIntegrationTest.java +++ b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/H2MultipleTypesIntegrationTest.java @@ -27,39 +27,33 @@ public void typesCoverageTestSuccessful(String driverClass, String url, String u System.out.println("Testing for url -> " + url); try { - executeUpdate(conn, - """ - drop table test_table - """); + executeUpdate(conn, "drop table test_table"); } catch (Exception e) { //Might not find it, not an issue } executeUpdate(conn, - """ - create table test_table( - val_int INT NOT NULL, - val_varchar VARCHAR(50) NOT NULL, - val_double_precision DOUBLE PRECISION, - val_bigint BIGINT, - val_tinyint TINYINT, - val_smallint SMALLINT, - val_boolean BOOLEAN, - val_decimal DECIMAL, - val_float FLOAT(2), - val_byte BINARY, - val_binary BINARY(4), - val_date DATE, - val_time TIME, - val_timestamp TIMESTAMP) - """); + "create table test_table(" + + " val_int INT NOT NULL," + + " val_varchar VARCHAR(50) NOT NULL," + + " val_double_precision DOUBLE PRECISION," + + " val_bigint BIGINT," + + " val_tinyint TINYINT," + + " val_smallint SMALLINT," + + " val_boolean BOOLEAN," + + " val_decimal DECIMAL," + + " val_float FLOAT(2)," + + " val_byte BINARY," + + " val_binary BINARY(4)," + + " val_date DATE," + + " val_time TIME," + + " val_timestamp TIMESTAMP)" + ); java.sql.PreparedStatement psInsert = conn.prepareStatement( - """ - insert into test_table (val_int, val_varchar, val_double_precision, val_bigint, val_tinyint, - val_smallint, val_boolean, val_decimal, val_float, val_byte, val_binary, val_date, val_time, - val_timestamp) - values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) - """ + "insert into test_table (val_int, val_varchar, val_double_precision, val_bigint, val_tinyint, " + + "val_smallint, val_boolean, val_decimal, val_float, val_byte, val_binary, val_date, val_time, " + + "val_timestamp) " + + "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" ); psInsert.setInt(1, 1); @@ -115,11 +109,7 @@ insert into test_table (val_int, val_varchar, val_double_precision, val_bigint, Assert.assertEquals("11:12:13", sdfTime.format(resultSet.getTime("val_time"))); Assert.assertEquals("30/03/2025 21:22:23", sdfTimestamp.format(resultSet.getTimestamp("val_timestamp"))); - executeUpdate(conn, - """ - delete from test_table where val_int=1 - """ - ); + executeUpdate(conn, "delete from test_table where val_int=1"); ResultSet resultSetAfterDeletion = psSelect.executeQuery(); Assert.assertFalse(resultSetAfterDeletion.next()); diff --git a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/PostgresMiniStressTest.java b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/PostgresMiniStressTest.java index e04d4c3..a4ea7c6 100644 --- a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/PostgresMiniStressTest.java +++ b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/PostgresMiniStressTest.java @@ -990,20 +990,20 @@ private static void runExactQuerySequence(int threadNum, String driverClass, Str // Heavy query, will fail every time timeAndRun(() -> { try (Connection conn = getConnection(driverClass, url, user, password)) { - try (PreparedStatement pst = conn.prepareStatement(""" - SELECT - u.id, - COUNT(o.id) AS num_orders, - SUM(oi.quantity) AS total_quantity, - AVG(p.price) AS avg_price, - (SELECT AVG(rating) FROM reviews WHERE product_id = p.id) AS avg_rating, - 1 / 0 AS failHere - FROM users u - JOIN orders o ON u.id = o.user_id - JOIN order_items oi ON o.id = oi.order_id - JOIN products p ON oi.product_id = p.id - GROUP BY u.id, p.id - """)) { + try (PreparedStatement pst = conn.prepareStatement( + "SELECT" + + " u.id," + + " COUNT(o.id) AS num_orders," + + " SUM(oi.quantity) AS total_quantity," + + " AVG(p.price) AS avg_price," + + " (SELECT AVG(rating) FROM reviews WHERE product_id = p.id) AS avg_rating," + + " 1 / 0 AS failHere" + + "FROM users u" + + "JOIN orders o ON u.id = o.user_id" + + "JOIN order_items oi ON o.id = oi.order_id" + + "JOIN products p ON oi.product_id = p.id" + + "GROUP BY u.id, p.id" + )) { try (ResultSet rs = pst.executeQuery()) { while (rs.next()) { rs.getInt(1); diff --git a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/ReadMultipleBlocksOfDataIntegrationTest.java b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/ReadMultipleBlocksOfDataIntegrationTest.java index c773fef..ebee73c 100644 --- a/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/ReadMultipleBlocksOfDataIntegrationTest.java +++ b/ojp-jdbc-driver/src/test/java/openjdbcproxy/jdbc/ReadMultipleBlocksOfDataIntegrationTest.java @@ -21,19 +21,15 @@ public void multiplePagesOfRowsResultSetSuccessful(int totalRecords, String driv System.out.println("Testing retrieving " + totalRecords + " records from url -> " + url); try { - executeUpdate(conn, - """ - drop table test_table_multi - """); + executeUpdate(conn, "drop table test_table_multi"); } catch (Exception e) { //Does not matter } executeUpdate(conn, - """ - create table test_table_multi( - id INT NOT NULL, - title VARCHAR(50) NOT NULL) - """); + "create table test_table_multi(" + + "id INT NOT NULL, " + + "title VARCHAR(50) NOT NULL)" + ); for (int i = 0; i < totalRecords; i++) { //TODO make this test parameterized with multiple parameters executeUpdate(conn, @@ -52,11 +48,7 @@ title VARCHAR(50) NOT NULL) Assert.assertEquals("TITLE_" + i, title); } - executeUpdate(conn, - """ - delete from test_table_multi - """ - ); + executeUpdate(conn, "delete from test_table_multi"); ResultSet resultSetAfterDeletion = psSelect.executeQuery(); Assert.assertFalse(resultSetAfterDeletion.next()); diff --git a/ojp-jdbc-driver/src/test/resources/postgres_connection.csv b/ojp-jdbc-driver/src/test/resources/postgres_connection.csv index 9b9a218..9c3684e 100644 --- a/ojp-jdbc-driver/src/test/resources/postgres_connection.csv +++ b/ojp-jdbc-driver/src/test/resources/postgres_connection.csv @@ -1 +1 @@ -org.openjdbcproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_postgresql://:5431/postgres,postgres,mysecretpassword \ No newline at end of file +org.openjdbcproxy.jdbc.Driver,jdbc:ojp[localhost:1059]_postgresql://:5432/defaultdb,testuser,testpassword \ No newline at end of file diff --git a/ojp-server/pom.xml b/ojp-server/pom.xml index 3a86bbf..b1e5dbe 100644 --- a/ojp-server/pom.xml +++ b/ojp-server/pom.xml @@ -15,6 +15,9 @@ + 22 + 22 + 1.70.0 2.0.17 3.4.5 @@ -61,7 +64,6 @@ 6.2.1 - org.apache.commons @@ -77,7 +79,6 @@ provided - org.slf4j diff --git a/pom.xml b/pom.xml index bf1af89..32b136e 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,6 @@ - 22 - 22 UTF-8