From fbae516439cf09d22ad7e4b625b841ea5a984662 Mon Sep 17 00:00:00 2001 From: jasonli-improving Date: Thu, 8 Feb 2024 13:45:06 -0800 Subject: [PATCH] add supported methods to dialects --- .../GenericTargetDriverDialect.java | 91 ++++++++++++++----- .../MariadbTargetDriverDialect.java | 69 ++++++++++++-- .../MysqlConnectorJTargetDriverDialect.java | 21 ++++- .../PgTargetDriverDialect.java | 47 +++++++++- 4 files changed, 191 insertions(+), 37 deletions(-) diff --git a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/GenericTargetDriverDialect.java b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/GenericTargetDriverDialect.java index 0ffa4472e..b6e1b779e 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/GenericTargetDriverDialect.java +++ b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/GenericTargetDriverDialect.java @@ -36,25 +36,70 @@ public class GenericTargetDriverDialect implements TargetDriverDialect { private static final Logger LOGGER = Logger.getLogger(GenericTargetDriverDialect.class.getName()); - public static final String METHOD_GET_AUTO_COMMIT = "Connection.getAutoCommit"; - public static final String METHOD_GET_CATALOG = "Connection.getCatalog"; - public static final String METHOD_GET_SCHEMA = "Connection.getSchema"; - public static final String METHOD_GET_TRANSACTION_ISOLATION = "Connection.getTransactionIsolation"; - public static final String METHOD_GET_NETWORK_TIME = "Connection.getNetworkTimeout"; - public static final String METHOD_GET_METADATA = "Connection.getMetaData"; - public static final String METHOD_IS_READ_ONLY = "Connection.isReadOnly"; - public static final String METHOD_GET_HOLDABILITY = "Connection.getHoldability"; - public static final String METHOD_GET_CLIENT_INFO = "Connection.getClientInfo"; - public static final String METHOD_GET_TYPE_MAP = "Connection.getTypeMap"; - public static final String METHOD_CLEAR_WARNINGS = "Statement.clearWarnings"; - public static final String METHOD_GET_CONNECTION = "Statement.getConnection"; - public static final String METHOD_GET_FETCH_DIRECTION = "Statement.getFetchDirection"; - public static final String METHOD_GET_FETCH_SIZE = "Statement.getFetchSize"; - public static final String METHOD_GET_MAX_FIELD_SIZE = "Statement.getMaxFieldSize"; - public static final String METHOD_GET_RESULT_HOLDABILITY = "Statement.getResultSetHoldability"; - public static final String METHOD_GET_RESULT_SET_TYPE = "Statement.getResultSetType"; - public static final String METHOD_IS_CLOSED = "Statement.isClosed"; - public static final String METHOD_CLOSE_ON_COMPLETION = "Statement.isCloseOnCompletion"; + public static final String CONN_GET_AUTO_COMMIT = "Connection.getAutoCommit"; + public static final String CONN_GET_CATALOG = "Connection.getCatalog"; + public static final String CONN_GET_SCHEMA = "Connection.getSchema"; + public static final String CONN_GET_TRANSACTION_ISOLATION = "Connection.getTransactionIsolation"; + public static final String CONN_GET_NETWORK_TIMEOUT = "Connection.getNetworkTimeout"; + public static final String CONN_GET_METADATA = "Connection.getMetaData"; + public static final String CONN_IS_READ_ONLY = "Connection.isReadOnly"; + public static final String CONN_GET_HOLDABILITY = "Connection.getHoldability"; + public static final String CONN_GET_CLIENT_INFO = "Connection.getClientInfo"; + public static final String CONN_GET_TYPE_MAP = "Connection.getTypeMap"; + public static final String CONN_CREATE_CLOB = "Connection.createClob"; + public static final String CONN_CREATE_BLOB = "Connection.createBlob"; + public static final String CONN_CREATE_NCLOB = "Connection.createNClob"; + public static final String CONN_IS_CLOSED = "Connection.isClosed"; + public static final String CONN_CLEAR_WARNINGS = "Connection.clearWarnings"; + public static final String CONN_SET_HOLDABILITY = "Connection.setHoldability"; + public static final String CONN_SET_SCHEMA = "Connection.setSchema"; + public static final String STATEMENT_CLEAR_WARNINGS = "Statement.clearWarnings"; + public static final String STATEMENT_GET_CONNECTION = "Statement.getConnection"; + public static final String STATEMENT_GET_FETCH_DIRECTION = "Statement.getFetchDirection"; + public static final String STATEMENT_GET_FETCH_SIZE = "Statement.getFetchSize"; + public static final String STATEMENT_GET_MAX_FIELD_SIZE = "Statement.getMaxFieldSize"; + public static final String STATEMENT_GET_RESULT_SET_HOLDABILITY = "Statement.getResultSetHoldability"; + public static final String STATEMENT_GET_RESULT_SET_TYPE = "Statement.getResultSetType"; + public static final String STATEMENT_IS_CLOSED = "Statement.isClosed"; + public static final String STATEMENT_IS_CLOSE_ON_COMPLETION = "Statement.isCloseOnCompletion"; + public static final String STATEMENT_CLEAR_BATCH = "Statement.clearBatch"; + public static final String STATEMENT_CLOSE_ON_COMPLETION = "Statement.closeOnCompletion"; + public static final String STATEMENT_GET_LARGE_MAX_ROWS = "Statement.getLargeMaxRows"; + public static final String STATEMENT_GET_GENERATED_KEYS = "Statement.getGeneratedKeys"; + public static final String STATEMENT_GET_MAX_ROWS = "Statement.getMaxRows"; + public static final String STATEMENT_GET_MORE_RESULTS = "Statement.getMoreResults"; + public static final String STATEMENT_GET_QUERY_TIMEOUT = "Statement.getQueryTimeout"; + public static final String STATEMENT_GET_RESULT_SET = "Statement.getResultSet"; + public static final String STATEMENT_GET_RESULT_SET_CONCURRENCY = "Statement.getResultSetConcurrency"; + public static final String STATEMENT_GET_UPDATE_COUNT = "Statement.getUpdateCount"; + public static final String STATEMENT_GET_WARNINGS = "Statement.getWarnings"; + public static final String STATEMENT_ADD_BATCH = "Statement.addBatch"; + public static final String CALL_GET_ARRAY = "CallableStatement.getArray"; + public static final String CALL_GET_BIG_DECIMAL = "CallableStatement.getBigDecimal"; + public static final String CALL_GET_BLOB = "CallableStatement.getBlob"; + public static final String CALL_GET_BOOLEAN = "CallableStatement.getBoolean"; + public static final String CALL_GET_BYTE = "CallableStatement.getByte"; + public static final String CALL_GET_BYTES = "CallableStatement.getBytes"; + public static final String CALL_GET_CHARACTER_STREAM = "CallableStatement.getCharacterStream"; + public static final String CALL_GET_CLOB = "CallableStatement.getClob"; + public static final String CALL_GET_DATE = "CallableStatement.getDate"; + public static final String CALL_GET_DOUBLE = "CallableStatement.getDouble"; + public static final String CALL_GET_FLOAT = "CallableStatement.getFloat"; + public static final String CALL_GET_INT = "CallableStatement.getInt"; + public static final String CALL_GET_LONG = "CallableStatement.getLong"; + public static final String CALL_GET_N_CLOB = "CallableStatement.getNClob"; + public static final String CALL_GET_N_CHAR = "CallableStatement.getNCharacterStream"; + public static final String CALL_GET_N_STRING = "CallableStatement.getNString"; + public static final String CALL_GET_OBJECT = "CallableStatement.getObject"; + public static final String CALL_GET_SHORT = "CallableStatement.getShort"; + public static final String CALL_GET_SQLXML = "CallableStatement.getSQLXML"; + public static final String CALL_GET_TIME = "CallableStatement.getTime"; + public static final String CALL_GET_STRING = "CallableStatement.getString"; + public static final String CALL_GET_TIMESTAMP = "CallableStatement.getTimestamp"; + public static final String CALL_GET_URL = "CallableStatement.getURL"; + public static final String CALL_WAS_NULL = "CallableStatement.wasNull"; + public static final String PREP_ADD_BATCH = "PreparedStatement.addBatch"; + public static final String PREP_CLEAR_PARAMS = "PreparedStatement.clearParameters"; @Override public boolean isDialect(Driver driver) { @@ -129,9 +174,9 @@ public boolean ping(@NonNull Connection connection) { @Override public List getAllowedOnConnectionMethodNames() { return Arrays.asList( - METHOD_GET_SCHEMA, - METHOD_GET_CATALOG, - METHOD_GET_AUTO_COMMIT, - METHOD_GET_TRANSACTION_ISOLATION); + CONN_GET_SCHEMA, + CONN_GET_CATALOG, + CONN_GET_AUTO_COMMIT, + CONN_GET_TRANSACTION_ISOLATION); } } diff --git a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MariadbTargetDriverDialect.java b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MariadbTargetDriverDialect.java index 99befc288..c40891274 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MariadbTargetDriverDialect.java +++ b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MariadbTargetDriverDialect.java @@ -19,7 +19,6 @@ import java.sql.Driver; import java.sql.SQLException; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Properties; import javax.sql.DataSource; @@ -101,13 +100,67 @@ public void registerDriver() throws SQLException { @Override public List getAllowedOnConnectionMethodNames() { return Arrays.asList( - METHOD_GET_METADATA, - METHOD_IS_READ_ONLY, - METHOD_GET_AUTO_COMMIT, - METHOD_GET_HOLDABILITY, - METHOD_GET_CLIENT_INFO, - METHOD_GET_NETWORK_TIME, - METHOD_GET_TYPE_MAP + CONN_GET_CATALOG, + CONN_GET_METADATA, + CONN_IS_READ_ONLY, + CONN_GET_SCHEMA, + CONN_GET_AUTO_COMMIT, + CONN_GET_HOLDABILITY, + CONN_GET_CLIENT_INFO, + CONN_GET_NETWORK_TIMEOUT, + CONN_GET_TYPE_MAP, + CONN_CREATE_CLOB, + CONN_CREATE_BLOB, + CONN_CREATE_NCLOB, + CONN_IS_CLOSED, + CONN_CLEAR_WARNINGS, + CONN_SET_HOLDABILITY, + CONN_SET_SCHEMA, + STATEMENT_CLEAR_WARNINGS, + STATEMENT_GET_CONNECTION, + STATEMENT_GET_FETCH_DIRECTION, + STATEMENT_GET_FETCH_SIZE, + STATEMENT_GET_MAX_FIELD_SIZE, + STATEMENT_GET_RESULT_SET_HOLDABILITY, + STATEMENT_GET_RESULT_SET_TYPE, + STATEMENT_IS_CLOSED, + STATEMENT_IS_CLOSE_ON_COMPLETION, + STATEMENT_CLEAR_BATCH, + STATEMENT_CLOSE_ON_COMPLETION, + STATEMENT_GET_LARGE_MAX_ROWS, + STATEMENT_GET_GENERATED_KEYS, + STATEMENT_GET_MAX_ROWS, + STATEMENT_GET_MORE_RESULTS, + STATEMENT_GET_QUERY_TIMEOUT, + STATEMENT_GET_RESULT_SET, + STATEMENT_GET_RESULT_SET_CONCURRENCY, + STATEMENT_GET_UPDATE_COUNT, + STATEMENT_ADD_BATCH, + CALL_GET_ARRAY, + CALL_GET_BIG_DECIMAL, + CALL_GET_BLOB, + CALL_GET_BOOLEAN, + CALL_GET_BYTE, + CALL_GET_BYTES, + CALL_GET_CHARACTER_STREAM, + CALL_GET_CLOB, + CALL_GET_DATE, + CALL_GET_DOUBLE, + CALL_GET_FLOAT, + CALL_GET_INT, + CALL_GET_LONG, + CALL_GET_N_CHAR, + CALL_GET_N_CLOB, + CALL_GET_N_STRING, + CALL_GET_OBJECT, + CALL_GET_SHORT, + CALL_GET_TIME, + CALL_GET_STRING, + CALL_GET_TIMESTAMP, + CALL_GET_URL, + CALL_WAS_NULL, + PREP_ADD_BATCH, + PREP_CLEAR_PARAMS ); } } diff --git a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MysqlConnectorJTargetDriverDialect.java b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MysqlConnectorJTargetDriverDialect.java index 58a3a630a..5fb5248df 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MysqlConnectorJTargetDriverDialect.java +++ b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/MysqlConnectorJTargetDriverDialect.java @@ -22,7 +22,6 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Properties; import javax.sql.DataSource; @@ -109,6 +108,24 @@ public boolean ping(@NonNull Connection connection) { @Override public List getAllowedOnConnectionMethodNames() { - return super.getAllowedOnConnectionMethodNames(); + return Arrays.asList( + CONN_GET_CATALOG, + CONN_IS_READ_ONLY, + CONN_GET_AUTO_COMMIT, + CONN_GET_HOLDABILITY, + CONN_GET_CLIENT_INFO, + CONN_GET_NETWORK_TIMEOUT, + CONN_GET_TYPE_MAP, + CONN_CREATE_CLOB, + CONN_CREATE_BLOB, + CONN_CREATE_NCLOB, + CONN_IS_CLOSED, + CONN_SET_HOLDABILITY, + STATEMENT_GET_CONNECTION, + STATEMENT_GET_FETCH_DIRECTION, + STATEMENT_GET_RESULT_SET_HOLDABILITY, + STATEMENT_IS_CLOSED, + STATEMENT_GET_LARGE_MAX_ROWS + ); } } diff --git a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/PgTargetDriverDialect.java b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/PgTargetDriverDialect.java index cdb9dae49..800644364 100644 --- a/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/PgTargetDriverDialect.java +++ b/wrapper/src/main/java/software/amazon/jdbc/targetdriverdialect/PgTargetDriverDialect.java @@ -19,18 +19,15 @@ import java.sql.Driver; import java.sql.SQLException; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Properties; import java.util.Set; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import javax.sql.DataSource; import org.checkerframework.checker.nullness.qual.NonNull; import software.amazon.jdbc.HostSpec; import software.amazon.jdbc.PropertyDefinition; -import software.amazon.jdbc.util.Messages; import software.amazon.jdbc.util.PropertyUtils; public class PgTargetDriverDialect extends GenericTargetDriverDialect { @@ -123,6 +120,48 @@ public void registerDriver() throws SQLException { @Override public List getAllowedOnConnectionMethodNames() { - return super.getAllowedOnConnectionMethodNames(); + return Arrays.asList( + CONN_IS_CLOSED, + STATEMENT_CLEAR_WARNINGS, + STATEMENT_GET_CONNECTION, + STATEMENT_GET_FETCH_DIRECTION, + STATEMENT_GET_FETCH_SIZE, + STATEMENT_GET_MAX_FIELD_SIZE, + STATEMENT_GET_RESULT_SET_HOLDABILITY, + STATEMENT_GET_RESULT_SET_TYPE, + STATEMENT_IS_CLOSED, + STATEMENT_IS_CLOSE_ON_COMPLETION, + STATEMENT_CLEAR_BATCH, + STATEMENT_CLOSE_ON_COMPLETION, + STATEMENT_GET_LARGE_MAX_ROWS, + STATEMENT_GET_GENERATED_KEYS, + STATEMENT_GET_MAX_ROWS, + STATEMENT_GET_MORE_RESULTS, + STATEMENT_GET_QUERY_TIMEOUT, + STATEMENT_GET_RESULT_SET, + STATEMENT_GET_RESULT_SET_CONCURRENCY, + STATEMENT_GET_UPDATE_COUNT, + STATEMENT_GET_WARNINGS, + STATEMENT_ADD_BATCH, + CALL_GET_ARRAY, + CALL_GET_BIG_DECIMAL, + CALL_GET_BOOLEAN, + CALL_GET_BYTE, + CALL_GET_BYTES, + CALL_GET_DATE, + CALL_GET_DOUBLE, + CALL_GET_FLOAT, + CALL_GET_INT, + CALL_GET_LONG, + CALL_GET_OBJECT, + CALL_GET_SHORT, + CALL_GET_SQLXML, + CALL_GET_TIME, + CALL_GET_STRING, + CALL_GET_TIMESTAMP, + CALL_WAS_NULL, + PREP_ADD_BATCH, + PREP_CLEAR_PARAMS + ); } }