From 9644ab2921a8f981c82968973cf33323325c9792 Mon Sep 17 00:00:00 2001 From: Laird Nelson Date: Fri, 20 Jan 2023 10:07:59 -0800 Subject: [PATCH] Introduces JtaConnection.java (#5905) Signed-off-by: Laird Nelson --- .../jdbc/DelegatingPreparedStatement.java | 3 +- .../integrations/jdbc/SQLSupplier.java | 39 + .../jta/jdbc/etc/spotbugs/exclude.xml | 2 +- .../jta/jdbc/JtaAdaptingDataSource.java | 250 ++++ .../integrations/jta/jdbc/JtaConnection.java | 1214 +++++++++++++++++ .../jta/jdbc/TestJtaConnection.java | 407 ++++++ .../TestTransactionSpecificConnection.java | 165 +++ 7 files changed, 2078 insertions(+), 2 deletions(-) create mode 100644 integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/SQLSupplier.java create mode 100644 integrations/jta/jdbc/src/main/java/io/helidon/integrations/jta/jdbc/JtaAdaptingDataSource.java create mode 100644 integrations/jta/jdbc/src/main/java/io/helidon/integrations/jta/jdbc/JtaConnection.java create mode 100644 integrations/jta/jdbc/src/test/java/io/helidon/integrations/jta/jdbc/TestJtaConnection.java create mode 100644 integrations/jta/jdbc/src/test/java/io/helidon/integrations/jta/jdbc/TestTransactionSpecificConnection.java diff --git a/integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/DelegatingPreparedStatement.java b/integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/DelegatingPreparedStatement.java index 611a6ae95f5..4a34512fc49 100644 --- a/integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/DelegatingPreparedStatement.java +++ b/integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/DelegatingPreparedStatement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Oracle and/or its affiliates. + * Copyright (c) 2022, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,6 +61,7 @@ public class DelegatingPreparedStatement extends De * @param strictClosedChecking if {@code true}, then this {@link DelegatingPreparedStatement}'s {@link * #isClosed()} method will be invoked before every operation that cannot take place on a closed statement, and, if * it returns {@code true}, the operation in question will fail with a {@link SQLException} + * * @exception NullPointerException if either argument is {@code * null} * diff --git a/integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/SQLSupplier.java b/integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/SQLSupplier.java new file mode 100644 index 00000000000..39b1f06db4d --- /dev/null +++ b/integrations/jdbc/jdbc/src/main/java/io/helidon/integrations/jdbc/SQLSupplier.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.helidon.integrations.jdbc; + +import java.sql.SQLException; + +/** + * A useful functional interface whose implementations can perform work that may throw a {@link SQLException}. + * + * @param the type of the object supplied + * + * @see #get() + */ +@FunctionalInterface +public interface SQLSupplier { + + /** + * Performs work and returns the result. + * + * @return the result of the work + * + * @exception SQLException if a database access error occurs + */ + T get() throws SQLException; + +} diff --git a/integrations/jta/jdbc/etc/spotbugs/exclude.xml b/integrations/jta/jdbc/etc/spotbugs/exclude.xml index 4d51b840347..970ca624b0f 100644 --- a/integrations/jta/jdbc/etc/spotbugs/exclude.xml +++ b/integrations/jta/jdbc/etc/spotbugs/exclude.xml @@ -1,6 +1,6 @@