Giter VIP home page Giter VIP logo

aws-mysql-jdbc's Introduction

Amazon Web Services (AWS) JDBC Driver for MySQL

Build Status Maven Central Javadoc License: GPLv2 with FOSS exception

The Amazon Web Services (AWS) JDBC Driver for MySQL allows an application to take advantage of the features of clustered MySQL databases. It is based on and can be used as a drop-in compatible for the MySQL Connector/J driver, and is compatible with all MySQL deployments.

The AWS JDBC Driver for MySQL supports fast failover for Amazon Aurora with MySQL compatibility. Support for additional features of clustered databases, including features of Amazon RDS for MySQL and on-premises MySQL deployments, is planned.

What is Failover?

An Amazon Aurora DB cluster uses failover to automatically repairs the DB cluster status when a primary DB instance becomes unavailable. During failover, Aurora promotes a replica to become the new primary DB instance, so that the DB cluster can provide maximum availability to a primary read-write DB instance. The AWS JDBC Driver for MySQL is designed to coordinate with this behavior in order to provide minimal downtime in the event of a DB instance failure.

Benefits of the AWS JDBC Driver for MySQL

Although Aurora is able to provide maximum availability through the use of failover, existing client drivers do not fully support this functionality. This is partially due to the time required for the DNS of the new primary DB instance to be fully resolved in order to properly direct the connection. The AWS JDBC Driver for MySQL fully utilizes failover behavior by maintaining a cache of the Aurora cluster topology and each DB instance's role (Aurora Replica or primary DB instance). This topology is provided via a direct query to the Aurora database, essentially providing a shortcut to bypass the delays caused by DNS resolution. With this knowledge, the AWS JDBC Driver can more closely monitor the Aurora DB cluster status so that a connection to the new primary DB instance can be established as fast as possible. Additionally, as noted above, the AWS JDBC Driver is designed to be a drop-in compatible for other MySQL JDBC drivers and can be used to interact with RDS and MySQL databases as well as Aurora MySQL.

Differences between the AWS MySQL JDBC driver and the AWS JDBC Driver

The AWS JDBC Driver for MySQL is based on the open-sourced MySQL Connector/J JDBC driver and allows users to take advantage of the features of Amazon Aurora databases. The AWS JDBC driver for MySQL can be used only with MySQL databases or MySQL-compatible Amazon RDS and Amazon Aurora clusters.

The AWS JDBC Driver provides similar functionalities, but is not specific to a certain vendor database. This driver instead uses a feature layer for JDBC on top of an existing database driver that the user specifies. It was designed to work with multiple relational databases and also different drivers, whether they are community-based or proprietary drivers. The AWS JDBC Driver currently supports the MySQL and PostgreSQL databases.

Once the AWS JDBC Driver was released, it was decided new features would not be added to the AWS JDBC Driver for MySQL and that future development would be taking place in the AWS JDBC Driver project. More details can be found in the maintenance policy. The AWS JDBC Driver for MySQL is now behind in terms of features and only receives security and critical fixes. The current maintenance window for the AWS JDBC Driver for MySQL ends on July 25, 2024, and it is recommended to migrate to the AWS JDBC Driver before that date. There is a migration guide available in the AWS JDBC Driver documentation to assist users through the migration process.

For new users who are wondering which one driver to use, it is recommended to use the AWS JDBC Driver.

Getting Started

Prerequisites

You need to install Amazon Corretto 8+ or Java 8+ before using the AWS JDBC Driver for MySQL.

Installing or Upgrading the AWS JDBC Driver for MySQL

Direct Download of the .jar file

The AWS JDBC Driver for MySQL can be installed from pre-compiled packages that can be downloaded directly from GitHub Releases or Maven Central. To install the driver, obtain the corresponding JAR file and include it in the application's CLASSPATH:

Example - Direct download with wget

wget https://github.com/awslabs/aws-mysql-jdbc/releases/download/1.1.14/aws-mysql-jdbc-1.1.14.jar
cp aws-mysql-jdbc-1.1.14.jar /home/userx/libs/
export CLASSPATH=$CLASSPATH:/home/userx/libs/aws-mysql-jdbc-1.1.14.jar

Upgrading to a newer version with wget

To upgrade the driver, replace the .jar file of your earlier driver with the new .jar file. After replacing the .jar file, update the CLASSPATH to include the name of the new file. For example, to upgrade to version 1.1.14:

wget https://github.com/awslabs/aws-mysql-jdbc/releases/download/1.1.14/aws-mysql-jdbc-1.1.14.jar
cp aws-mysql-jdbc-1.1.14.jar /home/userx/libs/
export CLASSPATH=$CLASSPATH:/home/userx/libs/aws-mysql-jdbc-1.1.14.jar

As a Maven dependency

You can use Maven's dependency management to obtain the driver by adding the following configuration to the application's Project Object Model (POM) file:

Example - Maven

<dependencies>
  <dependency>
    <groupId>software.aws.rds</groupId>
    <artifactId>aws-mysql-jdbc</artifactId>
    <version>1.1.14</version>
  </dependency>
</dependencies>

Upgrading to a newer version with Maven

To upgrade to a newer version of the driver, replace the version number identified in the pom.xml file with the newer driver version. For example, to upgrade to version 1.1.14, modify the file to include:

<dependencies>
  <dependency>
    <groupId>software.aws.rds</groupId>
    <artifactId>aws-mysql-jdbc</artifactId>
    <version>1.1.14</version>
  </dependency>
</dependencies>

As a Gradle dependency

You can use Gradle's dependency management to obtain the driver by adding the following configuration to the application's build.gradle file:

Example - Gradle

dependencies {
    implementation group: 'software.aws.rds', name: 'aws-mysql-jdbc', version: '1.1.14'
}

Upgrading to a newer version with Gradle

To upgrade to a newer version of the driver, replace the version number identified in the application's build.gradle file with the newer driver version. For example, to upgrade to version 1.1.14:

dependencies {
    implementation group: 'software.aws.rds', name: 'aws-mysql-jdbc', version: '1.1.14'
}

Using an IDE (IntelliJ)

To use the driver with an IDE (for example, IntelliJ), download the .jar file and copy it into your libs folder. Then, add the file to your CLASSPATH:

Example - IntelliJ

wget https://github.com/awslabs/aws-mysql-jdbc/releases/download/1.1.14/aws-mysql-jdbc-1.1.14.jar
cp aws-mysql-jdbc-1.1.14.jar /home/userx/libs/
export CLASSPATH=$CLASSPATH:/home/userx/libs/aws-mysql-jdbc-1.1.14.jar

After downloading the .jar file and updating the CLASSPATH, add the driver information to your Project:

  1. Open Project Structure in the IntelliJ user interface.

  2. Select Modules.

  3. Open the Dependencies tab for your project.

  4. Add the AWS JDBC Driver for MySQL .jar file.

  5. Update the connection URL prefix from jdbc:mysql:// to jdbc:mysql:aws://.

Upgrading to a newer version with IntelliJ

To upgrade to a newer version of the driver, download the updated driver, and add it to your CLASSPATH:

wget https://github.com/awslabs/aws-mysql-jdbc/releases/download/1.1.14/aws-mysql-jdbc-1.1.14.jar
cp aws-mysql-jdbc-1.1.14.jar /home/userx/libs/
export CLASSPATH=$CLASSPATH:/home/userx/libs/aws-mysql-jdbc-1.1.14.jar

Then, follow the steps listed above to update your project to the latest version.

Using the Driver with a database client (DBeaver)

To use the driver with the DBeaver database client, download the .jar file, copy the file to your libs folder, and add the file to your CLASSPATH:

Example - DBeaver

wget https://github.com/awslabs/aws-mysql-jdbc/releases/download/1.1.14/aws-mysql-jdbc-1.1.14.jar
cp aws-mysql-jdbc-1.1.14.jar /home/userx/libs/
export CLASSPATH=$CLASSPATH:/home/userx/libs/aws-mysql-jdbc-1.1.14.jar

After downloading the .jar file and adding it to your CLASSPATH, add the driver information to the DBeaver client:

  1. Open DBeaver’s Driver Manager window and click New to add the AWS JDBC Driver.

  2. In Settings, enter the following information:

    Default Port: 3306
    Driver Name: AWS JDBC Driver for MySQL
    Class Name: software.aws.rds.jdbc.mysql.Driver
    URL Template: jdbc:mysql:aws://{host}:{port}
  3. Go to the Libraries tab, click Add Artifact and add the following dependency declaration:

    <dependency>
      <groupId>software.aws.rds</groupId>
      <artifactId>aws-mysql-jdbc</artifactId>
    </dependency>
  4. DBeaver will respond: Artifacts Found: 1.

  5. (Optional) To enable database selector in the UI, you can add custom queries to DBeaver. Go to the Advanced parameters and edit the following queries:

    Get active database: select database()
    Set active database: use ?
  6. Click OK to finish adding the driver.

After adding driver information, you can create new connections that use the AWS JDBC Driver for MySQL.

Upgrading to a newer version with the DBeaver Client

To upgrade to a newer version of the driver, download the updated driver, and add it to your CLASSPATH:

wget https://github.com/awslabs/aws-mysql-jdbc/releases/download/1.1./aws-mysql-jdbc-1.1.14.jar
cp aws-mysql-jdbc-1.1.14.jar /home/userx/libs/
export CLASSPATH=$CLASSPATH:/home/userx/libs/aws-mysql-jdbc-1.1.14.jar

Then, follow the steps listed above to update your DBeaver client settings.

Using a Snapshot of the Driver

If there is an unreleased feature you would like to try, it may be available in a snapshot build of the driver. Snapshot builds can be found here. To use a snapshot, find the desired .jar file, which will be named aws-mysql-jdbc-<version>-<date>-<time>-<snapshot-number>.jar, and add it to your project as a dependency.

As a Maven dependency

<dependencies>
  <dependency>
    <groupId>software.aws.rds</groupId>
    <artifactId>aws-mysql-jdbc</artifactId>
    <version>1.1.15</version>
    <scope>system</scope>
    <systemPath>path-to-snapshot-jar</systemPath>
  </dependency>
</dependencies>

As a Gradle dependency

dependencies {
    implementation(files("path-to-snapshot-jar"))
}

Using the AWS JDBC Driver for MySQL

The AWS JDBC Driver for MySQL is drop-in compatible, so usage is identical to the MySQL-Connector-J JDBC driver. The sections below highlight driver usage specific to failover.

Driver Name

Use the driver name: software.aws.rds.jdbc.mysql.Driver. You'll need the driver name when loading the driver explicitly to the driver manager.

Connection URL Descriptions

There are many different types of URLs that can connect to an Aurora DB cluster; this section outlines the various URL types. For some URL types, the AWS JDBC Driver requires the user to provide some information about the Aurora DB cluster to provide failover functionality. For each URL type, information is provided below on how the driver will behave and what information the driver requires about the DB cluster, if applicable.

Note: The connection string follows standard URL parameters. In order to add parameters to the connection string, simply add ? and then the parameter_name=value pair at the end of the connection string. You may add multiple parameters by separating the parameter name and value set (parameter_name=value) with the & symbol. For example, to add 2 parameters simply add ?param_name=value&param_2=value2 at the end of the connection string.

URL Type Example Required Parameters Driver Behavior
Cluster Endpoint jdbc:mysql:aws://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:3306 None Initial connection: primary DB instance
Failover behavior: connect to the new primary DB instance
Read-Only Cluster Endpoint jdbc:mysql:aws://db-identifier.cluster-ro-XYZ.us-east-2.rds.amazonaws.com:3306 None Initial connection: any Aurora Replica
Failover behavior: prioritize connecting to any active Aurora Replica but might connect to the primary DB instance if it provides a connection first
Instance Endpoint jdbc:mysql:aws://instance-1.XYZ.us-east-2.rds.amazonaws.com:3306 None Initial connection: the instance specified (DB instance 1)
Failover behavior: connect to the primary DB instance
RDS Custom Cluster jdbc:mysql:aws://db-identifier.cluster-custom-XYZ.us-east-2.rds.amazonaws.com:3306 None The driver does not support custom clusters yet. Initial connection: the primary instance in the cluster
Failover behavior: connect to the primary DB instance
IP Address jdbc:mysql:aws://10.10.10.10:3306 clusterInstanceHostPattern Initial connection: the DB instance specified
Failover behavior: connect to the primary DB instance
Custom Domain jdbc:mysql:aws://my-custom-domain.com:3306 clusterInstanceHostPattern Initial connection: the DB instance specified
Failover behavior: connect to the primary DB instance
Non-Aurora Endpoint jdbc:mysql:aws://localhost:3306 None A regular JDBC connection will be returned - no failover functionality
Aurora Endpoint
(through a custom tunnel)
jdbc:mysql:aws://localhost:3306 clusterInstanceHostPattern Initial connection: the DB instance specified
Failover behavior: connect to the primary DB instance

Information about the clusterInstanceHostPattern parameter is provided in the section below.

For more information about parameters that can be configured with the AWS JDBC Driver, see the section below about failover parameters.

Connection Plugin Manager

The connection plugin manager initializes, triggers, and cleans up a chain of connection plugins. Connection plugins are widgets attached to each Connection object to help execute additional or supplementary logic related to that Connection. Failover and Enhanced Failure Monitoring are both examples of connection plugins.

Failover and Enhanced Failure Monitoring are loaded by default. Additional custom plugins can be implemented and used alongside existing ones. Plugins can be loaded in a specific order to create a chain, and each plugin will pass its results to the next.

NOTE: Loading custom plugins will not include Enhanced Failure Monitoring and the Failover Connection Plugin unless explicitly stated through the connectionPluginFactories parameter.

The figure above shows a simplified workflow of the connection plugin manager.

Starting at the top, when a JDBC method is executed by the driver, it is passed to the connection plugin manager. From the connection plugin manager, the JDBC method is passed in order to each plugin, and loaded like a chain. In this example, the method is passed first to Custom Plugin A, then to Custom Plugin B, and finally to Default Plugin which executes the JDBC method and returns the result back through the chain.

By default, the Enhanced Failure Monitoring plugin is loaded. Additional custom plugins can be implemented and used alongside existing ones. You can chain plugins together in a specified order. Loaded custom plugins will not include the Enhanced Failure Monitoring plugin unless explicitly stated with the connectionPluginFactories parameter.

The AWS JDBC Driver for MySQL attaches the DefaultConnectionPlugin to the tail of the connection plugin chain and actually executes the given JDBC method.

Since all the connection plugins are chained together, the earlier connection plugins affect the latter plugins. If the connection plugin at the head of the connection plugin chain measures the execution time, this measurement would encompass the time spent in all the connection plugins down the chain.

To learn how to write custom plugins, refer to examples located inside Custom Plugins Demo.

Connection Plugin Manager Parameters

Parameter Value Required Description Default Value
useConnectionPlugins Boolean No When set to the default value true, the connection plugins will be loaded, including the Failover and Enhanced Failure Monitor plugins. When set to false, the connection plugins will not be loaded and the driver will instead execute JDBC methods directly.

NOTE: Since the failover functionality and Enhanced Failure Monitoring are implemented with plugins, disabling connection plugins will also disable such functionality.
true
connectionPluginFactories String No String of fully-qualified class name of plugin factories that will create the plugin objects.

Each factory in the string should be comma-separated ,

NOTE: The order of factories declared matters.

Example: customplugins.MethodCountConnectionPluginFactory, customplugins.ExecutionTimeConnectionPluginFactory,software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory
software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPluginFactory, software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory

Failover Plugin

The failover plugin is loaded by default and can be disabled by setting parameter enableClusterAwareFailover to false.

The AWS JDBC Driver Failover Process

The figure above provides a simplified overview of how the AWS JDBC Driver handles an Aurora failover encounter. Starting at the top of the diagram, an application with the AWS JDBC Driver on its class path uses the driver to get a logical connection to an Aurora database.

In this example, the application requests a connection using the Aurora DB cluster endpoint and is returned a logical connection that contains a physical connection to DB instance C, the primary DB instance in the DB cluster. Due to how the application operates against the logical connection, the physical connection details about which specific DB instance it is connected to have been abstracted away.

Over the course of the application's lifetime, it executes various statements against the logical connection. If DB instance C is stable and active, these statements succeed and the application continues as normal. If DB instance C later experiences a failure, Aurora will initiate failover to promote a replica to a new primary DB instance (DB instance A or B in this case). At the same time, the AWS JDBC Driver will intercept the related communication exception and kick off its own internal failover process.

In this case, in which the primary DB instance has failed, the driver will use its internal topology cache to temporarily connect to an active Aurora Replica. The topology cache will contain information regarding which instances are available. The active Aurora Replica the driver has connected to will be periodically queried for the DB cluster topology until the new primary DB instance is identified (DB instance A or B).

At this point, the driver will connect to the new primary DB instance and return control to the application by raising a SQLException with SQLState 08S02 so that they can reconfigure their session state as required. Although the DNS endpoint for the DB cluster might not yet resolve to the new primary DB instance, the driver has already discovered this new DB instance during its failover process and will be directly connected to it when the application continues executing statements.

To the application, the logical connection will not appear to have changed, but the physical connection will have been swapped to the new primary DB instance. In this way the driver provides a faster way to reconnect to a newly promoted DB instance, thus increasing the availability of the DB cluster.

Failover Parameters

In addition to the parameters that you can configure for the MySQL Connector/J driver, you can pass the following parameters to the AWS JDBC Driver through the connection URL to specify additional driver behavior.

Parameter Value Required Description Default Value
enableClusterAwareFailover Boolean No Set to true to enable the fast failover behavior offered by the AWS JDBC Driver. Set to false for simple JDBC connections that do not require fast failover functionality.

NOTE: In addition to this parameter, since the failover functionality is implemented with connection plugins, disabling useConnectionPlugins will also disable the failover functionality. When useConnectionPlugins is enabled, the failover plugin will be loaded by default regardless of whether enableClusterAwareFailover is true or false.
true
clusterInstanceHostPattern String If connecting using an IP address or custom domain URL: Yes
Otherwise: No
This parameter is not required unless connecting to an AWS RDS cluster via an IP address or custom domain URL. In those cases, this parameter specifies the cluster instance DNS pattern that will be used to build a complete instance endpoint. A "?" character in this pattern should be used as a placeholder for the DB instance identifiers of the instances in the cluster.

Example: ?.my-domain.com, any-subdomain.?.my-domain.com:9999

Usecase Example: If you have a custom domain ( dev.rds.mydomain.com) as a CNAME to an RDS cluster (dev-cluster.cluster-cmdXXXXXX.eu-west-2.rds.amazonaws.com.) then the paramater is clusterInstanceHostPattern=?.cmdXXXXXX.eu-west-2.rds.amazonaws.com
If the provided connection string is not an IP address or custom domain, the driver will automatically acquire the cluster instance host pattern from the customer-provided connection string.
clusterId String No A unique identifier for the cluster. Connections with the same cluster ID share a cluster topology cache. This connection parameter is not required and thus should only be set if desired. The driver will automatically acquire a cluster id for AWS RDS clusters.
clusterTopologyRefreshRateMs Integer No Cluster topology refresh rate in milliseconds. The cached topology for the cluster will be invalidated after the specified time, after which it will be updated during the next interaction with the connection. 30000
failoverTimeoutMs Integer No Maximum allowed time in milliseconds to attempt reconnecting to a new writer or reader instance after a cluster failover is initiated. 60000
failoverClusterTopologyRefreshRateMs Integer No Cluster topology refresh rate in milliseconds during a writer failover process. During the writer failover process, cluster topology may be refreshed at a faster pace than normal to speed up discovery of the newly promoted writer. 5000
failoverWriterReconnectIntervalMs Integer No Interval of time in milliseconds to wait between attempts to reconnect to a failed writer during a writer failover process. 5000
failoverReaderConnectTimeoutMs Integer No Maximum allowed time in milliseconds to attempt to connect to a reader instance during a reader failover process. 5000
acceptAwsProtocolOnly Boolean If using simultaneously with another MySQL driver that supports the same protocols: Yes
Otherwise: No
Set to true to only accept connections for URLs with the jdbc:mysql:aws:// protocol. This setting should be set to true when running an application that uses this driver simultaneously with another MySQL driver that supports the same protocols (e.g. the MySQL JDBC Driver), to ensure the driver protocols do not clash. This behavior can also be set at the driver level for every connection via the Driver.setAcceptAwsProtocolOnly method; however, this connection parameter will take priority when present. false
gatherPerfMetrics Boolean No Set to true if you would like the driver to record failover-associated metrics.

To print collected metrics, call IClusterAwareMetricsReporter.reportMetrics(String connUrl, Log log).
e.g. IClusterAwareMetricsReporter.reportMetrics(db-identifier.cluster-ro-XYZ.us-east-2.rds.amazonaws.com:3306, myLog)

To reset collected metrics, call IClusterAwareMetricsReporter.reportMetrics().
false
gatherMetricsPerInstance Boolean No Set to true to gather additional performance metrics per instance as well as cluster. Set to false to only gather performance metrics per cluster.

To print collected metrics at instance level, call IClusterAwareMetricsReporter.reportMetrics(String connUrl, Log log, true).
false
allowXmlUnsafeExternalEntity Boolean No Set to true if you would like to use XML inputs that refer to external entities. WARNING: Setting this to true is unsafe since your system to be prone to XXE attacks. false
keepSessionStateOnFailover Boolean No This parameter will allow connections to retain the session state after failover. When keepSessionStateOnFailover is set to false, connections will need to be reconfigured as seen in the examples here. When this parameter is true, the autocommit, sessionMaxRows and transactionIsolation values will be kept. This parameter is only necessary when the session state must be retained and the connection cannot be manually reconfigured by the user.

Please note: this parameter will not be able to fully restore the connection session state, as it will only save the autocommit, sessionMaxRows and transactionIsolation values.
false
enableFailoverStrictReader Boolean No Set to true to only allow failover to reader nodes during the reader failover process. If enabled, reader failover to a writer node will only be allowed for single-node clusters. This logic mimics the logic of the Aurora read-only cluster endpoint. false

Failover Exception Codes

08001 - Unable to Establish SQL Connection

When the driver throws a SQLException with code 08001, the original connection failed, and the driver tried to failover to a new instance, but was not able to. There are various reasons this may happen: no nodes were available, a network failure occurred, and so on. In this scenario, please wait until the server is up or other problems are solved (an exception will be thrown.)

08S02 - Communication Link

When the driver throws a SQLException with code 08S02, the original connection failed while autocommit was set to true, and the driver successfully failed over to another available instance in the cluster. However, any session state configuration of the initial connection is now lost. In this scenario, you should:

  • Reconfigure and reuse the original connection (the reconfigured session state will be the same as the original connection).

  • Repeat the query that was executed when the connection failed and continue work as desired.

Sample Code

import java.sql.*;

/**
 * Scenario 1: Failover happens when autocommit is set to true - Catch SQLException with code 08S02.
 */
public class FailoverSampleApp1 {

   private static final String CONNECTION_STRING = "jdbc:mysql:aws://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:3306/employees";
   private static final String USERNAME = "username";
   private static final String PASSWORD = "password";
   private static final int MAX_RETRIES = 5;

   public static void main(String[] args) throws SQLException {
      try (Connection conn = DriverManager.getConnection(CONNECTION_STRING, USERNAME, PASSWORD)) {
         // Configure the connection.
         setInitialSessionState(conn);

         // Do something with method "betterExecuteQuery" using the Cluster-Aware Driver.
         String select_sql = "SELECT * FROM employees";
         try (ResultSet rs = betterExecuteQuery(conn, select_sql)) {
            while (rs.next()) {
               System.out.println(rs.getString("first_name"));
            }
         }
      }
   }

   private static void setInitialSessionState(Connection conn) throws SQLException {
      // Your code here for the initial connection setup.
      try (Statement stmt1 = conn.createStatement()) {
         stmt1.executeUpdate("SET time_zone = \"+00:00\"");
      }
   }

   // A better executing query method when autocommit is set as the default value - true.
   private static ResultSet betterExecuteQuery(Connection conn, String query) throws SQLException {
      // Record the times of retry.
      int retries = 0;

      while (true) {
         try {
            Statement stmt = conn.createStatement();
            return stmt.executeQuery(query);
         } catch (SQLException e) {
            // If the attempt to connect has failed MAX_RETRIES times,            
            // throw the exception to inform users of the failed connection.
            if (retries > MAX_RETRIES) {
               throw e;
            }

            // Failover has occurred and the driver has failed over to another instance successfully.
            if ("08S02".equalsIgnoreCase(e.getSQLState())) {
               // Reconfigure the connection.
               setInitialSessionState(conn);
               // Re-execute that query again.
               retries++;

            } else {
               // If some other exception occurs, throw the exception.
               throw e;
            }
         }
      }
   }
}

08007 - Transaction Resolution Unknown

When the driver throws a SQLException with code 08007, the original connection failed within a transaction (while autocommit was set to false). In this scenario, the driver first attempts to rollback the transaction and then fails over to another available instance in the cluster. Note that the rollback might be unsuccessful as the initial connection may be broken at the time that the driver recognizes the problem. Note also that any session state configuration of the initial connection is now lost. In this scenario, you should:

  • Reconfigure and reuse the original connection (the reconfigured session state will be the same as the original connection).

  • Re-start the transaction and repeat all queries which were executed during the transaction before the connection failed.

  • Repeat the query that was executed when the connection failed and continue work as desired.

If autocommit is set to false, and the connection cannot be reconfigured manually by the user, the failover parameter keepSessionStateOnFailover can be used to retain some session parameters, as they would be reset otherwise.

Sample Code

import java.sql.*;

/**
 * Scenario 2: Failover happens when autocommit is set to false - Catch SQLException with code 08007.
 */
public class FailoverSampleApp2 {

   private static final String CONNECTION_STRING = "jdbc:mysql:aws://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:3306/employees";
   private static final String USERNAME = "username";
   private static final String PASSWORD = "password";
   private static final int MAX_RETRIES = 5;

   public static void main(String[] args) throws SQLException {
      String[] update_sql = {
              "INSERT INTO employees(emp_no, birth_date, first_name, last_name, gender, hire_date) VALUES (5000000, '1958-05-01', 'John', 'Doe', 'M', '1997-11-30')",
              "INSERT INTO employees(emp_no, birth_date, first_name, last_name, gender, hire_date) VALUES (5000001, '1958-05-01', 'Mary', 'Malcolm', 'F', '1997-11-30')",
              "INSERT INTO employees(emp_no, birth_date, first_name, last_name, gender, hire_date) VALUES (5000002, '1958-05-01', 'Tom', 'Jerry', 'M', '1997-11-30')"
      };

      try (Connection conn = DriverManager.getConnection(CONNECTION_STRING, USERNAME, PASSWORD)) {
         // Configure the connection - set autocommit to false.
         setInitialSessionState(conn);

         // Do something with method "betterExecuteUpdate_setAutoCommitFalse" using the Cluster-Aware Driver.           
         betterExecuteUpdate_setAutoCommitFalse(conn, update_sql);
      }
   }

   private static void setInitialSessionState(Connection conn) throws SQLException {
      // Your code here for the initial connection setup.
      try (Statement stmt1 = conn.createStatement()) {
         stmt1.executeUpdate("SET time_zone = \"+00:00\"");
      }
      conn.setAutoCommit(false);
   }

   // A better executing query method when autocommit is set to false.
   private static void betterExecuteUpdate_setAutoCommitFalse(Connection conn, String[] queriesInTransaction) throws SQLException {
      // Create a boolean flag.
      boolean isSuccess = false;
      // Record the times of retry.
      int retries = 0;

      while (!isSuccess) {
         try (Statement stmt = conn.createStatement()) {
            for (String sql : queriesInTransaction) {
               stmt.executeUpdate(sql);
            }
            conn.commit();
            isSuccess = true;
         } catch (SQLException e) {

            // If the attempt to connect has failed MAX_RETRIES times,
            // rollback the transaction and throw the exception to inform users of the failed connection.
            if (retries > MAX_RETRIES) {
               conn.rollback();
               throw e;
            }

            // Failure happens within the transaction and the driver failed over to another instance successfully.
            if ("08007".equalsIgnoreCase(e.getSQLState())) {
               // Reconfigure the connection, restart the transaction.
               setInitialSessionState(conn);
               // Re-execute every queries that were inside the transaction.
               retries++;

            } else {
               // If some other exception occurs, rollback the transaction and throw the exception.
               conn.rollback();
               throw e;
            }
         }
      }
   }
}

Connection Pooling

The AWS JDBC Driver for MySQL is compatible with connection pooling, but some connection pooling libraries may contain additional behaviour when dealing with SQL exceptions. This means the exceptions created by the AWS JDBC Driver for MySQL may not be recognized, and depending on the connection pool, connections may be closed prematurely due to the unrecognized SQL exceptions. Users are recommended to investigate the connection pooling library of their choice, and to implement any required additional code to allow the connection pool to accept the exceptions raised by the driver. For example, the library HikariCP has an interface that users can implement to prevent connections from being closed immediately after failover, as seen below.

Sample Code

import com.zaxxer.hikari.SQLExceptionOverride;

import java.sql.SQLException;

public class HikariCPSQLException implements SQLExceptionOverride {
    public Override adjudicate(final SQLException sqlException) {
        String sqlState = sqlException.getSQLState();
        if (sqlState.equalsIgnoreCase("08S02") ||
            sqlState.equalsIgnoreCase("08007")) {
            return Override.DO_NOT_EVICT;
        } else {
            return Override.CONTINUE_EVICT;
        }
    }
}

⚠️ Warnings About Proper Usage of the AWS JDBC Driver for MySQL

  1. A common practice when using JDBC drivers is to wrap invocations against a Connection object in a try-catch block, and dispose of the Connection object if an Exception is hit. If your application takes this approach, it will lose the fast-failover functionality offered by the Driver. When failover occurs, the Driver internally establishes a ready-to-use connection inside the original Connection object before throwing an exception to the user. If this Connection object is disposed of, the newly established connection will be thrown away. The correct practice is to check the SQL error code of the exception and reuse the Connection object if the error code indicates successful failover. FailoverSampleApp1 and FailoverSampleApp2 demonstrate this practice. See the section below on Failover Exception Codes for more details.
  2. It is highly recommended that you use the cluster and read-only cluster endpoints instead of the direct instance endpoints of your Aurora cluster, unless you are confident about your application's usage of instance endpoints. Although the Driver will correctly failover to the new writer instance when using instance endpoints, use of these endpoints is discouraged because individual instances can spontaneously change reader/writer status when failover occurs. The driver will always connect directly to the instance specified if an instance endpoint is provided, so a write-safe connection cannot be assumed if the application uses instance endpoints.

Enhanced Failure Monitoring

The figure above shows a simplified workflow of Enhanced Failure Monitoring. Enhanced Failure Monitoring is a connection plugin implemented by a monitor thread. The monitor will periodically check the connected database node's health. If a database node is determined to be unhealthy, the query will be retried with a new database node and the monitor restarted.

The Enhanced Failure Monitoring plugin is loaded by default, and can be disabled by setting parameter failureDetectionEnabled to false.

If custom connection plugins are loaded, Enhanced Failure Monitoring and Failover Connection Plugin will NOT be loaded unless explicitly included by adding software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPluginFactory,software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory to connectionPluginFactories.

Enhanced Failure Monitoring Parameters

failureDetectionTime, failureDetectionInterval, and failureDetectionCount are similar to TCP Keep Alive parameters.

You can include additional monitoring configurations by adding the prefix monitoring- to the configuration key.

Parameter Value Required Description Default Value
failureDetectionEnabled Boolean No Set to true to enable Enahanced Failure Monitoring. Set to false to disable it.

NOTE: In addition to this parameter, since the Enhanced Failure Monitor is implemented with connection plugins, disabling useConnectionPlugins will also disable the Enhanced Failure Monitor functionality. When useConnectionPlugins is enabled, the Enhanced Failure Monitor plugin will be loaded by default regardless of whether failureDetectionEnabled is true or false.
true
failureDetectionTime Integer No Interval in milliseconds between sending a SQL query to the server and the first probe to the database node. 30000
failureDetectionInterval Integer No Interval in milliseconds between probes to database node. 5000
failureDetectionCount Integer No Number of failed connection checks before considering database node as unhealthy. 3
monitorDisposalTime Integer No Interval in milliseconds for a monitor to be considered inactive and to be disposed. 60000

⚠️ Warnings About Usage of the AWS JDBC Driver for MySQL with RDS Proxy

Using RDS Proxy endpoints with AWS JDBC Driver for MySQL with Enhanced Failure Monitoring plugin doesn't cause any critical issue. However such approach isn't recommended. The main reason is that RDS Proxy transparently re-routes driver requests to one of database instances. RDS Proxy decides which database instance is used to based on many criteria and it's on per request basis. Such switching from between different instances makes the plugin useless in terms of instance health monitoring. The plugin couldn't identify what actual instance it's connected to and which one it's monitoring. That could be a source of false positive failure detections. At the same time the plugin can still proactively monitor network connectivity to RDS Proxy endpoints and report outages back to a user application if they occur.

It is suggested to turn off Enhanced Failure Monitoring plugin, or to avoid using RDS Proxy endpoints when the plugin is active.

Experimental Enhanced Failure Monitoring Plugin v2

Warning

This plugin is experimental and users should test the plugin before using it in production environment.

Enhanced Failure Monitoring Plugin v2 is an alternative implementation of enhanced failure monitoring, and it is functionally equal to the Enhanced Failure Monitoring Plugin described above. Both plugins share the same set of configuration parameters. Enhanced Failure Monitoring Plugin v2 plugin is designed to be a drop-in replacement for the Enhanced Failure Monitoring Plugin.

Note

Since these two plugins are separate plugins, users may decide to use them together with a single connection. While this should not have any negative side effects, it is not recommended. It is recommended to use either the Enhanced Failure Monitoring Plugin, or the Enhanced Failure Monitoring Plugin v2 where it's needed.

In order to use Enhanced Failure Monitoring Plugin v2, users should add software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.efm2.NodeMonitoringConnectionPluginFactory to connectionPluginFactories.

Enhanced Failure Monitoring Plugin v2 is designed to address some of the issues that have been reported by multiple users. The following changes have been made:

  • Used weak pointers to ease garbage collection
  • Split monitoring logic into two separate threads to increase overall monitoring stability
  • Reviewed locks for monitoring context
  • Reviewed and redesigned stopping of idle monitoring threads
  • Reviewed and simplified monitoring logic

AWS Secrets Manager Plugin

The AWS JDBC Driver for MySQL supports usage of database credentials stored in the AWS Secrets Manager through the AWS Secrets Manager Plugin. This plugin is optional and can be enabled with the connectionPluginFactories parameter as seen in the connection plugin manager parameters table. When a user creates a new connection with this plugin enabled, the plugin will retrieve the secret and the connection will be created using those credentials.

Note: To use this plugin, you must include the runtime dependencies Jackson Databind and AWS Secrets Manager in your project.

The following properties are required for the AWS Secrets Manager Plugin to retrieve secrets.

Parameter Value Required Description Example
secretsManagerSecretId String Yes Set this value to be the secret name or the secret ARN. test-secret-id
secretsManagerRegion String Yes Set this value to be the region your secret is in. us-east-1

Example

import java.sql.*;
import java.util.Properties;
import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPluginFactory;

public class AWSSecretsManagerPluginSample {

   private static final String CONNECTION_STRING = "jdbc:mysql:aws://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:3306/employees";
   private static final String SECRET_ID = "secretId";
   private static final String REGION = "us-east-1";

   public static void main(String[] args) throws SQLException {
      final Properties properties = new Properties();
      // Enable the AWS Secrets Manager Plugin:
      properties.setProperty("connectionPluginFactories", AWSSecretsManagerPluginFactory.class.getName());
      
      // Set these properties so secrets can be retrieved:
      properties.setProperty("secretsManagerSecretId", SECRET_ID);
      properties.setProperty("secretsManagerRegion", REGION);

      // Try and make a connection:
      try (final Connection conn = DriverManager.getConnection(CONNECTION_STRING, properties);
           final Statement statement = conn.createStatement();
           final ResultSet rs = statement.executeQuery("SELECT * FROM employees")) {
         while (rs.next()) {
            System.out.println(rs.getString("first_name"));
         }
      }
   }
}

Reader Cluster Connection Plugin

When connecting to an Amazon Aurora database using the reader endpoint, the endpoint will load balance connections between all the available Aurora Replicas. In situations where the AWS JDBC Driver for MySQL needs to create a new connection internally, the new connection may or may not be to the same instance the original connection was made to. This means any processes that require the same instance will result in errors. For example, setting query timeouts may result in errors due to the kill query being sent to the incorrect instance. In these cases, the Reader Cluster Connection Plugin can be used to ensure all new connections are made to the same reader.

The Reader Cluster Connection Plugin is not enabled by default and can be enabled by using the connectionPluginFactories.

Extra Additions

XML Entity Injection Fix

The default XML parser contained a security risk which made the driver prone to XML Entity Injection (XXE) attacks. To solve this issue, we disabled Document Type Definitions (DTDs) in the XML parser. If you require this restriction to be lifted in your application, you can set the allowXmlUnsafeExternalEntity parameter in the connection string to true. Please see the table below for a definition of this parameter.

Parameter Value Required Description Default Value
allowXmlUnsafeExternalEntity Boolean No Set to true if you would like to use XML inputs that refer to external entities. WARNING: Setting this to true is unsafe since your system to be prone to XXE attacks. false

AWS IAM Database Authentication

Note: To preserve compatibility with customers using the community driver, IAM Authentication requires the AWS Java SDK RDS v2.x to be included separately in the classpath. The AWS Java SDK RDS is a runtime dependency and must be resolved.

The driver supports Amazon AWS Identity and Access Management (IAM) authentication. When using AWS IAM database authentication, the host URL must be a valid Amazon endpoint, and not a custom domain or an IP address.
ie. db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com

IAM database authentication use is limited to certain database engines. For more information on limitations and recommendations, please review the IAM documentation.

Setup for IAM database Authentication for MySQL

  1. Turn on AWS IAM database authentication for the existing database or create a new database on the AWS RDS Console:
    1. If needed, review the documentation about creating a new database.
    2. If needed, review the documentation about modifying an existing database.
  2. Create/Change and use an AWS IAM policy for AWS IAM database authentication.
  3. Create a database account using AWS IAM database authentication:
    1. Connect to your MySQL database using master logins, and use the following command to create a new user:
      CREATE USER example_user_name IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS';
Parameter Value Required Description Default Value
useAwsIam Boolean No Set to true to enable AWS IAM database authentication false
Sample Code
import java.sql.*;
import java.util.Properties;

public class AwsIamAuthenticationSample {

   private static final String CONNECTION_STRING = "jdbc:mysql:aws://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:3306/employees";
   private static final String USER = "username";

   public static void main(String[] args) throws SQLException {
      final Properties properties = new Properties();
      // Enable AWS IAM database authentication
      properties.setProperty("useAwsIam", "true");
      properties.setProperty("user", USER);

      // Try and make a connection
      try (final Connection conn = DriverManager.getConnection(CONNECTION_STRING, properties);
           final Statement statement = conn.createStatement();
           final ResultSet rs = statement.executeQuery("SELECT * FROM employees")) {
         while (rs.next()) {
            System.out.println(rs.getString("first_name"));
         }
      }
   }
}

Development

Setup

After installing Amazon Corretto or Java as directed in the prerequisites section, use the following command to clone the driver repository:

$ git clone https://github.com/awslabs/aws-mysql-jdbc.git
$ cd aws-mysql-jdbc

You can now make changes in the repository.

Building the AWS JDBC Driver for MySQL

To build the AWS JDBC Driver, navigate into the aws-mysql-jdbc directory and run the following command:

gradlew build

To build the driver without running the tests, run the following command:

gradlew build -x test

Running the Tests

To run the tests, you must first install Docker. After building the driver, and installing and configuring Docker, you can run the tests in the aws-mysql-jdbc directory with the following command:

gradlew test

To run tests for the base driver functionality, use the following command:

gradlew test-community-docker

To run the integration tests, you will need some environment variables and an AWS User. Integration tests are set up to create clusters for each test. The AWS User will need access to do the following: create/delete Aurora clusters for testing, AWS IAM access for RDS, and allowlisting IP address of the current runner in EC2 Security Group. Descriptions of the necessary environment variables is in the table below.

To run the integration tests on macOS, use the following command (replace the variables with the appropriate values):

AWS_ACCESS_KEY_ID=ASIAIOSFODNN7EXAMPLE AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY AWS_SESSION_TOKEN=AQoDYXdzEJr...<remainder of session token> ./gradlew test-integration-docker

To run the integration tests on Windows, use the following command (replace the variables with the appropriate values):

cmd /c "SET AWS_ACCESS_KEY_ID=ASIAIOSFODNN7EXAMPLE & SET AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY & SET AWS_SESSION_TOKEN=AQoDYXdzEJr...<remainder of session token> .\gradlew test-integration-docker

Environment Variables

Environment Variable Required Description Example Value
AWS_ACCESS_KEY_ID Yes Access keys for CLI, SDK, & API access ASIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY Yes Secret Access keys for CLI, SDK, & API access wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_SESSION_TOKEN Required if using temporary AWS credentials. AWS Session Token for CLI, SDK, & API access. AQoDYXdzEJr...
TEST_DB_CLUSTER_IDENTIFIER No, but suggested to set The database identifier for your Aurora cluster. It is suggested to have this set to avoid conflicting with existing clusters. db-identifier
TEST_USERNAME No The username to access the database. username
TEST_PASSWORD No The database cluster password. password
TEST_DB_USER No User within the database that is identified with AWS IAM database authentication. This is used for AWS IAM authentication. jane_doe

Enable Logging

Enable logging by specifying the logger parameter in the connection string like the following:

jdbc:mysql:aws://database.cluster-xyz.us-east-2.rds.amazonaws.com/dbnname?logger=StandardLogger

For more information on the configuration parameter, see Debugging/Profiling. The driver currently does not support custom logging outside the usual logging frameworks like SLF4J. For more information on using SLF4J with the driver see here.

Known Limitations

Please note that as mentioned in the maintenance policy, there will not be any new feature work for the AWS JDBC Driver for MySQL. All new feature development will be targeted towards the AWS JDBC Driver, which can be used in place of the AWS JDBC Driver for MySQL. A migration guide containing instructions on how to transition from the AWS JDBC Driver for MySQL to the AWS JDBC Driver can be found here. We encourage you to check out the AWS JDBC Driver documentation and to consider whether it would be suitable for your needs.

Amazon RDS Blue/Green Deployments

This driver does not support Amazon RDS Blue/Green Deployments, and they should be avoided. Executing a Blue/Green deployment with the driver will disconnect the driver from the database, and it will be unable to re-establish a connection to an available database instance.

Amazon Aurora Global Databases

This driver does not support Amazon Aurora Global Databases. While it is possible to connect to global databases, failing over to a secondary cluster will result in errors and there may be additional unforeseen errors when working with global databases.

SSLHandshakeException

Using the driver with JDKs based on OpenJDK 8u292+ or OpenJDK 11.0.11+ will result in an exception: SSLHandshakeException: No appropriate protocol. This is due to OpenJDK disabling TLS 1.0 and 1.1 availability in security.properties. For additional information see "Disable TLS 1.0 and TLS 1.1". To resolve this exception, add the enabledTLSProtocols=TLSv1.2 connection property when connecting to a database.

Read-Write Splitting

The driver does not support read-write splitting yet. A possible solution for now is to utilize multiple connection pools. One can send write traffic to a connection pool connected to the writer cluster endpoint, and send read-only traffic to another pool connected to the reader cluster endpoint.

Password Expiration With AWS Secrets Manager

When using the driver with AWS Secrets Manager, the driver does not automatically update expired credentials during failover. The driver only handles expired credentials when opening new connections. If the credentials expire during failover, the driver raises a SQLException with SQLState 28000 to the client application. A possible solution to handle password expiration during failover is to catch SQLException with SQLState 28000 and create a new connection.

import java.sql.*;
import java.util.Properties;
import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPluginFactory;
import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPluginFactory;
import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory;
import com.mysql.cj.log.StandardLogger;

public class AWSSecretsManagerPluginSample2 {

   private static final String CONNECTION_STRING = "jdbc:mysql:aws://db-identifier.cluster-XYZ.us-east-2.rds.amazonaws.com:3306/employees";
   private static final String SECRET_ID = "secretId";
   private static final String REGION = "us-east-1";
   private static final int MAX_RETRIES = 5;

   public static void main(String[] args) throws SQLException {
      final Properties properties = new Properties();
      properties.setProperty("logger", StandardLogger.class.getName());

      // Enable the AWS Secrets Manager Plugin:
      properties.setProperty(
              "connectionPluginFactories",
              String.format("%s,%s,%s",
                      AWSSecretsManagerPluginFactory.class.getName(),
                      FailoverConnectionPluginFactory.class.getName(),
                      NodeMonitoringConnectionPluginFactory.class.getName())
      );

      // Set these properties so secrets can be retrieved:
      properties.setProperty("secretsManagerSecretId", SECRET_ID);
      properties.setProperty("secretsManagerRegion", REGION);

      try (ResultSet rs = executeQueryWithPasswordExpirationHandling("SELECT * FROM employees", properties)) {
         while (rs.next()) {
            System.out.println(rs.getString("first_name"));
         }
      }
   }

   private static ResultSet executeQueryWithPasswordExpirationHandling(
           String query,
           Properties properties) throws SQLException {
      int retries = 0;
      boolean reconnect = false;
      Connection connection = null;

      while (true) {
         try {
            if (connection == null || reconnect) {
               connection = DriverManager.getConnection(CONNECTION_STRING, properties);
            }
            Statement statement = connection.createStatement();
            return statement.executeQuery(query);
         } catch (SQLException e) {
            // If the attempt to connect has failed MAX_RETRIES times,
            // throw the exception to inform users of the failed connection.
            if (retries > MAX_RETRIES) {
               throw e;
            }

            if ("28000".equalsIgnoreCase(e.getSQLState())) {
               // Failover has occurred and failed due to access denied error.
               // Create a new connection and re-execute the query.
               reconnect = true;
               retries++;
            } else if ("08S02".equalsIgnoreCase(e.getSQLState())) {
               // Failover has occurred and the driver has failed over to another instance successfully.
               // Re-execute the query.
               retries++;
            } else {
               throw e;
            }
         }
      }
   }
}

Getting Help and Opening Issues

If you encounter a bug with the AWS JDBC Driver for MySQL, we would like to hear about it. Please search the existing issues and see if others are also experiencing the issue before opening a new issue. When opening a new issue, we will need the version of AWS JDBC Driver for MySQL, Java language version, OS you’re using, and the MySQL database version you're running against. Please include a reproduction case for the issue when appropriate.

The GitHub issues are intended for bug reports and feature requests. Keeping the list of open issues lean will help us respond in a timely manner.

Releases

The AWS JDBC Driver for MySQL has a regular monthly release cadence. A new release will occur during the last week of each month. However, if there are no changes since the latest release, then a release will not occur. The full release schedule and maintenance policy can be found here.

Aurora Engine Version Testing

The aws-mysql-jdbc driver is being tested against the following Community and Aurora database versions in our test suite:

Database Versions
MySQL 8.0.21
Aurora MySQL MySQL 5.7.mysql_aurora.2.11.2 (Wire-compatible with MySQL 5.7 onwards. For more details, see here.)

The aws-mysql-jdbc driver is compatible with MySQL 5.7 andMySQL 8.0 as per the Community MySQL Connector/J 8.0 Driver.

Documentation

For additional documentation on the AWS JDBC Driver, please refer to the documentation for the open-source mysql-connector-j driver that the AWS JDBC Driver is based on.

License

This software is released under version 2 of the GNU General Public License (GPLv2).

aws-mysql-jdbc's People

Contributors

aaronchung-bitquill avatar amazon-auto avatar buitcj avatar colinkyuen avatar congoamz avatar crystall-bitquill avatar davecramer avatar dependabot[bot] avatar faviansamatha avatar francis-a avatar geetanjalij avatar hsuamz avatar janickr avatar jasonlamz avatar jasonli-improving avatar joyc-bq avatar juanpabloprado avatar karenc-bq avatar lennehendrickx avatar matsev avatar nitesmeh avatar samathaamz avatar seneramz avatar sergiyv-improving avatar sergiyvamz avatar sertay-s avatar susanmdouglas-aws avatar tbutter avatar tomchiverton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-mysql-jdbc's Issues

Wrong Exception thrown for ResultSet getters when there are incompatible data types

Describe the bug

As the docs say the aurora mysql driver can be used as a drop-in compatible for the MySQL Connector/J driver, it might be expected that the aws mysql driver behaves as the mysql one. Calling ResultSet#getInt on a varchar column will cause a java.lang.NumberFormatException (e.g., java.lang.NumberFormatException: For input string: "hello world") in the aws mysql driver but in the MySQL driver it will cause a java.sql.SQLException (e.g., java.sql.SQLException: Invalid value for getInt() - 'hello world').

Expected Behavior

java.sql.SQLException is thrown

Current Behavior

java.lang.NumberFormatException is thrown

Reproduction Steps

Create a table with a varchar column and insert a row, for example: CREATE TABLE TT (val varchar(255)); INSERT INTO TT VALUES ('hello world');

Put both the MySQL and AWS MySQL drivers on the classpath and use the following code.

    software.aws.rds.jdbc.mysql.Driver.setAcceptAwsProtocolOnly(true);

    try (
        Connection conn = DriverManager.getConnection(jdbcUrl, userName, password);
        Statement statement = conn.createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT * FROM TT;");
    ) {
      while (resultSet.next()) {
        int firstVal = resultSet.getInt(1);
      }
    }

Using an AWS Aurora MySQL instance, use a mysql style jdbc URL to see the SQLException (e.g., jdbc:mysql://...) and use an aurora mysql style jdbc URL to see the NumberFormatException (e.g., jdbc:mysql:aws://...)

Possible Solution

Wrap the ResultSetImpl#get- methods with the wrapper code that some of the methods already have to make it consistent:

} catch (NumberFormatException nfe) {
            throw SQLError.createSQLException(

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.1

JDK version used

1.8

Operating System and version

MacOS Monterey 12.6.1

Datapipeline throws "Unsupported major.minor version 52.0"

Describe the issue
I've updated the driver to this in a Data Pipeline due to previous SSL errors.
Now it throws a "Unsupported major.minor version 52.0". I don't think it's possible to change the Java VM version in the DP runner instances.

Driver Version?
v1.0.0

Java Version?
no idea (AWS Data Pipeline runner default)

OS Version?
no idea (AWS Data Pipeline runner default)

MySQL Version?
Aurora MySQL 5.7

To Reproduce
Steps to reproduce the behaviour:

  • Upload the jar file to S3
  • Set up a Datapipeline with SQL source and point the drive to the S3 upload
  • Run the pipeline

Expected behaviour
Pipeline should read and process the RDS data
Instead it's throwing the error above

Logs

java.lang.UnsupportedClassVersionError: software/aws/rds/jdbc/mysql/Driver : Unsupported major.minor version 52.0 at
java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:808) at 
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at 
java.net.URLClassLoader.defineClass(URLClassLoader.java:443) at java.net.URLClassLoader.access$100(URLClassLoader.java:65) at 
java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.net.URLClassLoader$1.run(URLClassLoader.java:349) at 
java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:348) at 
java.lang.ClassLoader.loadClass(ClassLoader.java:430) at java.lang.ClassLoader.loadClass(ClassLoader.java:363) at 
java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:278) at 
amazonaws.datapipeline.database.JdbcDriverInitializer.getDriver(JdbcDriverInitializer.java:75) at 
amazonaws.datapipeline.database.ConnectionFactory.getJdbcDatabaseConnection(ConnectionFactory.java:223) at 
amazonaws.datapipeline.database.ConnectionFactory.getConnection(ConnectionFactory.java:76) at 
amazonaws.datapipeline.database.ConnectionFactory.getConnectionWithCredentials(ConnectionFactory.java:302) at 
amazonaws.datapipeline.connector.SqlDataNode.createConnection(SqlDataNode.java:100) at 
amazonaws.datapipeline.connector.SqlDataNode.getConnection(SqlDataNode.java:94) at 
amazonaws.datapipeline.connector.SqlDataNode.prepareStatement(SqlDataNode.java:162) at 
amazonaws.datapipeline.connector.SqlInputConnector.open(SqlInputConnector.java:49) at 
amazonaws.datapipeline.connector.SqlInputConnector.<init>(SqlInputConnector.java:26) at 
amazonaws.datapipeline.connector.SqlDataNode.getInputConnector(SqlDataNode.java:79) at 
amazonaws.datapipeline.activity.copy.SingleThreadedCopyActivity.processAll(SingleThreadedCopyActivity.java:47) at 
amazonaws.datapipeline.activity.copy.SingleThreadedCopyActivity.runActivity(SingleThreadedCopyActivity.java:35) at 
amazonaws.datapipeline.activity.CopyActivity.runActivity(CopyActivity.java:22) at 
amazonaws.datapipeline.objects.AbstractActivity.run(AbstractActivity.java:16) at 
amazonaws.datapipeline.taskrunner.TaskPoller.executeRemoteRunner(TaskPoller.java:136) at 
amazonaws.datapipeline.taskrunner.TaskPoller.executeTask(TaskPoller.java:105) at 
amazonaws.datapipeline.taskrunner.TaskPoller$1.run(TaskPoller.java:81) at 
private.com.amazonaws.services.datapipeline.poller.PollWorker.executeWork(PollWorker.java:76) at 
private.com.amazonaws.services.datapipeline.poller.PollWorker.run(PollWorker.java:53) at java.lang.Thread.run(Thread.java:748) 

aws-jdbc-driver 1.1.0 + Hikari2.7.9 + AWSSecretsManagerPluginFactory - JDBC Connection is failing

Please help, we need this for our feature enhancements.

  • Spring boot
  • aws-jdbc-driver 1.1.0
  • Hikari2.7.9
  • AWSSecretsManagerPluginFactory
  • SecretsId is submitted through HikariConfig dataSourceProperties
    HikariConfig - dataSourceProperties............{secretsManagerSecretId=$validSecretIsd$, password=, secretsManagerRegion=us-east-1}

Refer to the following stack trace.
JDBC Connectivity is failing.
HikariConfig properties are in the following log output.
Please refer to 'jdbcUrl' & 'dataSourceProperties'
Looks like a problem in reading the secrets. Creds are empty

Error exception
169 2022-06-30T20:37:33.164-04:00 Caused by: software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.CJException: Access denied for user ''@'172.22.5.247' (using password: NO)

2022-06-30T20:37:33.191-04:00 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
2022-06-30T20:37:33.191-04:00 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778)
2022-06-30T20:37:33.191-04:00 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.DatabaseException: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
2022-06-30T20:37:33.191-04:00 30-06-2022 20:37:33.190 main [ERROR] SpringApplication - Application run failed
2022-06-30T20:37:33.191-04:00 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2022-06-30T20:37:33.191-04:00 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
2022-06-30T20:37:33.191-04:00 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2022-06-30T20:37:33.191-04:00 Caused by: software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.CJException: Access denied for user ''@'172.22.5.247' (using password: NO)
2022-06-30T20:37:33.191-04:00 ... 28 common frames omitted
2022-06-30T20:37:33.191-04:00 at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:266)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.HikariDataSource$$EnhancerBySpringCGLIB$$d17dd0d2.getConnection()
2022-06-30T20:37:33.191-04:00 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
2022-06-30T20:37:33.191-04:00 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
2022-06-30T20:37:33.191-04:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
2022-06-30T20:37:33.191-04:00 at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
2022-06-30T20:37:33.191-04:00 at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
2022-06-30T20:37:33.191-04:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
2022-06-30T20:37:33.191-04:00 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.HikariDataSource$$FastClassBySpringCGLIB$$eeb1ae86.invoke()
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:115)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:534)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:460)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:194)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:365)
2022-06-30T20:37:33.191-04:00 at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.autodetectClusterAndCreateProxyInstance(ConnectionProxy.java:126)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.(ConnectionProxy.java:91)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.(ConnectionProxy.java:79)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.(ConnectionProxy.java:104)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.initPluginManager(ConnectionProxy.java:283)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.DefaultConnectionPlugin.openInitialConnection(DefaultConnectionPlugin.java:104)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.BasicConnectionProvider.connect(BasicConnectionProvider.java:53)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:253)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.openInitialConnection(FailoverConnectionPlugin.java:219)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.createConnection(FailoverConnectionPlugin.java:1060)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPlugin.openInitialConnection(NodeMonitoringConnectionPlugin.java:255)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPlugin.openInitialConnection(AWSSecretsManagerPlugin.java:140)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPlugin.attemptConnectionWithSecrets(AWSSecretsManagerPlugin.java:170)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.ConnectionPluginManager.openInitialConnection(ConnectionPluginManager.java:151)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:910)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:460)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
2022-06-30T20:37:33.191-04:00 Caused by: liquibase.exception.DatabaseException: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
2022-06-30T20:37:33.191-04:00 at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:271)
2022-06-30T20:37:33.191-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
2022-06-30T20:37:33.191-04:00 Caused by: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
2022-06-30T20:37:33.191-04:00 ... 26 common frames omitted
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
2022-06-30T20:37:33.191-04:00 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2022-06-30T20:37:33.191-04:00 at java.lang.reflect.Method.invoke(Method.java:498)
2022-06-30T20:37:33.191-04:00 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2022-06-30T20:37:33.191-04:00 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2022-06-30T20:37:33.191-04:00 at com.dt.rts.eregusa.user.LoginApplication.main(LoginApplication.java:58)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
2022-06-30T20:37:33.191-04:00 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
2022-06-30T20:37:33.191-04:00 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
2022-06-30T20:37:33.191-04:00 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:709)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:787)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:129)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:854)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.NativeSession.connect(NativeSession.java:136)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1369)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:216)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:509)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:137)
2022-06-30T20:37:33.191-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:677)
2022-06-30T20:37:33.191-04:00 ... 62 common frames omitted
2022-06-30T20:37:33.188-04:00 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-06-30T20:37:33.188-04:00 2022-06-30T20:37:33.188-04:00
30-06-2022 20:37:33.188 main [INFO ] ConditionEvaluationReportLoggingListener -
2022-06-30T20:37:33.168-04:00 30-06-2022 20:37:33.168 main [INFO ] DirectJDKLog - Stopping service [Tomcat]
2022-06-30T20:37:33.165-04:00 30-06-2022 20:37:33.165 main [WARN ] AbstractApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.DatabaseException: java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
2022-06-30T20:37:33.164-04:00 30-06-2022 20:37:33.163 main [ERROR] HikariPool - LOGINHikariPool - Exception during pool initialization.
2022-06-30T20:37:33.164-04:00 java.sql.SQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up.
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:910)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.(ConnectionProxy.java:79)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.(ConnectionProxy.java:91)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.(ConnectionProxy.java:104)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.initPluginManager(ConnectionProxy.java:283)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.ConnectionPluginManager.openInitialConnection(ConnectionPluginManager.java:151)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.openInitialConnection(FailoverConnectionPlugin.java:219)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.createConnection(FailoverConnectionPlugin.java:1060)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPlugin.openInitialConnection(NodeMonitoringConnectionPlugin.java:255)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPlugin.openInitialConnection(AWSSecretsManagerPlugin.java:140)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPlugin.attemptConnectionWithSecrets(AWSSecretsManagerPlugin.java:170)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.DefaultConnectionPlugin.openInitialConnection(DefaultConnectionPlugin.java:104)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.BasicConnectionProvider.connect(BasicConnectionProvider.java:53)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:253)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:460)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:534)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:460)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:194)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:365)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:117)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.autodetectClusterAndCreateProxyInstance(ConnectionProxy.java:126)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.pool.HikariPool.(HikariPool.java:115)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.HikariDataSource$$FastClassBySpringCGLIB$$eeb1ae86.invoke()
2022-06-30T20:37:33.164-04:00 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
2022-06-30T20:37:33.164-04:00 at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:749)
2022-06-30T20:37:33.164-04:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
2022-06-30T20:37:33.164-04:00 at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:136)
2022-06-30T20:37:33.164-04:00 at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:124)
2022-06-30T20:37:33.164-04:00 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
2022-06-30T20:37:33.164-04:00 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
2022-06-30T20:37:33.164-04:00 at com.zaxxer.hikari.HikariDataSource$$EnhancerBySpringCGLIB$$d17dd0d2.getConnection()
2022-06-30T20:37:33.164-04:00 at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:266)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
151 2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
152 2022-06-30T20:37:33.164-04:00 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105)
153 2022-06-30T20:37:33.164-04:00 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
154 2022-06-30T20:37:33.164-04:00 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
155 2022-06-30T20:37:33.164-04:00 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
156 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
157 2022-06-30T20:37:33.164-04:00 at com.dt.rts.eregusa.user.LoginApplication.main(LoginApplication.java:58)
158 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
159 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
160 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
161 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
162 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
163 2022-06-30T20:37:33.164-04:00 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
164 2022-06-30T20:37:33.164-04:00 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
165 2022-06-30T20:37:33.164-04:00 at java.lang.reflect.Method.invoke(Method.java:498)
166 2022-06-30T20:37:33.164-04:00 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
167 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
168 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
169 2022-06-30T20:37:33.164-04:00 Caused by: software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.CJException: Access denied for user ''@'172.22.5.247' (using password: NO)
170 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
171 2022-06-30T20:37:33.164-04:00 at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
172 2022-06-30T20:37:33.164-04:00 at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
173 2022-06-30T20:37:33.164-04:00 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
174 2022-06-30T20:37:33.164-04:00 at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
175 2022-06-30T20:37:33.164-04:00 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
176 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
177 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:709)
178 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:787)
179 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:129)
180 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
181 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
182 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:216)
183 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:509)
184 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:137)
185 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.checkErrorMessage(NativeProtocol.java:677)
186 2022-06-30T20:37:33.164-04:00 .. 62 common frames omitted
187 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl.connectWithRetries(ConnectionImpl.java:854)
188 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.NativeSession.connect(NativeSession.java:136)
189 2022-06-30T20:37:33.164-04:00 at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1369)
190 2022-06-30T20:37:27.414-04:00 30-06-2022 20:37:27.414 main [INFO ] HikariDataSource - LOGINHikariPool - Starting...
191 2022-06-30T20:37:27.414-04:00 30-06-2022 20:37:27.414 main [DEBUG] HikariConfig - validationTimeout...............30000
192 2022-06-30T20:37:27.414-04:00 30-06-2022 20:37:27.413 main [DEBUG] HikariConfig - username........................none
193 2022-06-30T20:37:27.413-04:00 30-06-2022 20:37:27.413 main [DEBUG] HikariConfig - transactionIsolation............default
194 2022-06-30T20:37:27.413-04:00 30-06-2022 20:37:27.413 main [DEBUG] HikariConfig - threadFactory...................internal
195 2022-06-30T20:37:27.413-04:00 30-06-2022 20:37:27.413 main [DEBUG] HikariConfig - schema..........................none
196 2022-06-30T20:37:27.413-04:00 30-06-2022 20:37:27.413 main [DEBUG] HikariConfig - scheduledExecutorService........internal
197 2022-06-30T20:37:27.413-04:00 30-06-2022 20:37:27.413 main [DEBUG] HikariConfig - scheduledExecutor...............none
198 2022-06-30T20:37:27.413-04:00 30-06-2022 20:37:27.413 main [DEBUG] HikariConfig - registerMbeans..................true
199 2022-06-30T20:37:27.413-04:00 30-06-2022 20:37:27.412 main [DEBUG] HikariConfig - readOnly........................false
200 2022-06-30T20:37:27.412-04:00 30-06-2022 20:37:27.412 main [DEBUG] HikariConfig - poolName........................"LOGINHikariPool"
201 2022-06-30T20:37:27.412-04:00 30-06-2022 20:37:27.412 main [DEBUG] HikariConfig - password........................
202 2022-06-30T20:37:27.412-04:00 30-06-2022 20:37:27.412 main [DEBUG] HikariConfig - minimumIdle.....................5
203 2022-06-30T20:37:27.412-04:00 30-06-2022 20:37:27.412 main [DEBUG] HikariConfig - metricsTrackerFactory...........none
204 2022-06-30T20:37:27.412-04:00 30-06-2022 20:37:27.412 main [DEBUG] HikariConfig - metricRegistry..................none
205 2022-06-30T20:37:27.412-04:00 30-06-2022 20:37:27.411 main [DEBUG] HikariConfig - maximumPoolSize.................25
206 2022-06-30T20:37:27.411-04:00 30-06-2022 20:37:27.411 main [DEBUG] HikariConfig - maxLifetime.....................120000
207 2022-06-30T20:37:27.411-04:00 30-06-2022 20:37:27.411 main [DEBUG] HikariConfig - leakDetectionThreshold..........0
208 2022-06-30T20:37:27.411-04:00 30-06-2022 20:37:27.411 main [DEBUG] HikariConfig - jdbcUrl.........................jdbc:mysql:aws://<RDS_Cluster>:3306/?maxAllowedPacket=99999744&socketTimeout=30000&autoReconnect=true&serverTimezone=UTC&enabledTLSProtocols=TLSv1.2&connectionPluginFactories=software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPluginFactory,software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory, software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPluginFactory
209 2022-06-30T20:37:27.411-04:00 30-06-2022 20:37:27.411 main [DEBUG] HikariConfig - jdbc4ConnectionTest.............false
210 2022-06-30T20:37:27.411-04:00 30-06-2022 20:37:27.411 main [DEBUG] HikariConfig - isolateInternalQueries..........false
211 2022-06-30T20:37:27.411-04:00 30-06-2022 20:37:27.410 main [DEBUG] HikariConfig - initializationFailTimeout.......1
212 2022-06-30T20:37:27.410-04:00 30-06-2022 20:37:27.410 main [DEBUG] HikariConfig - initializationFailFast..........true
213 2022-06-30T20:37:27.410-04:00 30-06-2022 20:37:27.410 main [DEBUG] HikariConfig - idleTimeout.....................0
214 2022-06-30T20:37:27.410-04:00 30-06-2022 20:37:27.410 main [DEBUG] HikariConfig - healthCheckRegistry.............none
215 2022-06-30T20:37:27.410-04:00 30-06-2022 20:37:27.410 main [DEBUG] HikariConfig - healthCheckProperties...........{}
216 2022-06-30T20:37:27.410-04:00 30-06-2022 20:37:27.410 main [DEBUG] HikariConfig - driverClassName................."software.aws.rds.jdbc.mysql.Driver"
217 2022-06-30T20:37:27.410-04:00 30-06-2022 20:37:27.409 main [DEBUG] HikariConfig - dataSourceProperties............{secretsManagerSecretId=$validSecretsId$, password=, secretsManagerRegion=us-east-1}
218 2022-06-30T20:37:27.409-04:00 30-06-2022 20:37:27.409 main [DEBUG] HikariConfig - dataSourceJNDI..................none
219 2022-06-30T20:37:27.409-04:00 30-06-2022 20:37:27.409 main [DEBUG] HikariConfig - dataSourceClassName.............none
220 2022-06-30T20:37:27.409-04:00 30-06-2022 20:37:27.408 main [DEBUG] HikariConfig - dataSource......................none
221 2022-06-30T20:37:27.408-04:00 30-06-2022 20:37:27.408 main [DEBUG] HikariConfig - connectionTimeout...............60000
222 2022-06-30T20:37:27.408-04:00 30-06-2022 20:37:27.408 main [DEBUG] HikariConfig - connectionTestQuery............."SELECT 1 FROM DUAL"
223 2022-06-30T20:37:27.408-04:00 30-06-2022 20:37:27.408 main [DEBUG] HikariConfig - connectionInitSql...............none
224 2022-06-30T20:37:27.408-04:00 30-06-2022 20:37:27.408 main [DEBUG] HikariConfig - catalog.........................none
225 2022-06-30T20:37:27.408-04:00 30-06-2022 20:37:27.408 main [DEBUG] HikariConfig - autoCommit......................true
226 2022-06-30T20:37:27.408-04:00 30-06-2022 20:37:27.407 main [DEBUG] HikariConfig - allowPoolSuspension.............true

Even when there is no failure in aws, it shows connection failure.

I am getting this error very frequently after integrating AWS Jdbc driver v1.0 to spring boot application that uses hikari. Whenever it occur api calls takes much more time but there is no api call fail as such.

cc_config_pool_ro - Connection software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ConnectionImpl@6bb5d3e7 marked as broken because of SQLSTATE(08S02), ErrorCode(0)
java.sql.SQLException: The active SQL connection has changed due to a connection failure. Please re-configure session state if required.

java.sql.SQLException: The active SQL connection has changed due to a connection failure. Please re-configure session state if required.
	at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.failover(FailoverConnectionPlugin.java:500)
	at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.connectToWriterIfRequired(FailoverConnectionPlugin.java:771)
	at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.performSpecialMethodHandlingIfRequired(FailoverConnectionPlugin.java:1154)
	at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.execute(FailoverConnectionPlugin.java:251)
	at s.a.r.j.m.s.c.m.c.j.h.p.ConnectionPluginManager.execute(ConnectionPluginManager.java:133)
	at s.a.r.j.m.s.c.m.c.j.ha.ConnectionProxy.invoke(ConnectionProxy.java:188)
	at com.sun.proxy.$Proxy181.setReadOnly(Unknown Source)
	at com.zaxxer.hikari.pool.ProxyConnection.setReadOnly(ProxyConnection.java:423)
	at c.z.hikari.pool.HikariProxyConnection.setReadOnly(HikariProxyConnection.java)
	at o.s.jdbc.datasource.DataSourceUtils.resetConnectionAfterTransaction(DataSourceUtils.java:252)
	at o.s.o.j.v.HibernateJpaDialect$SessionTransactionData.resetSessionState(HibernateJpaDialect.java:399)
	at o.s.orm.jpa.vendor.HibernateJpaDialect.cleanupTransaction(HibernateJpaDialect.java:236)
	at o.s.orm.jpa.JpaTransactionManager.doCleanupAfterCompletion(JpaTransactionManager.java:614)
	at o.s.t.s.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:1004)
	at o.s.t.s.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:790)
	at o.s.t.s.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)
	at o.s.t.i.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:633)
	at o.s.t.i.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:386)
	at o.s.t.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118)
	at o.s.a.f.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:1...

is it recommended to use for production?

Describe the issue
I'm evaluating this driver to use on my application, but on the readme file I can see that say We encourage you to experiment with MySQL driver but DO NOT adopt it for production use So My question is I can see the 0.1.0 and 0.2.0 versions is it recommended to use any version on production

Driver Version?
0.1.0
0.2.0

Java Version?
11.0.12

OS Version?
macOS Big Sur 11.5.2

MySQL Version?
mysql:mysql-connector-java version:8.0.24
aws-mysql-jdbc version: '0.2.0

To Reproduce
N/A

Readonly connections Read-replica load-balancing

Hi,
A question. We currently use "jdbc:mysql:replication" driver with Aurora to achieve read-only connections balancing between multiple read replicas. As mysql driver has no knowledge of Aurora topology we have to list the write and all read replica enpoints explicitly, which is a chore and when the failover happens it screws up the application, but provides for an excellent read performance and even utilization of replica instances. Is this supported by AWS driver or are there plans to implement it? Would be nice if AWS driver can automatically send connections to relevant replicas based on the topology and write/read-only connection type. IMO without this functionality Aurora is not worth it for real production workloads
Thx

Unable to commit against JDBC Connection; nested exception is org.hibernate.TransactionException: Unable to commit against JDBC Connection

Describe the issue
A clear and concise description of what the issue is.

Driver Version?
aws-mysql-jdbc (version 1.0.0)
Java Version?

OS Version?

MySQL Version?
8.0.mysql_aurora.3.01.0
To Reproduce
Steps to reproduce the behaviour:

Expected behaviour
A clear and concise description of what you expected to happen.
And what actually happens

Logs
If possible MySQL logs surrounding the occurrence of the issue

AWS MySQL JDBC Driver does not recognize Aurora endpoint in China

Hi,

In China the autogenerated Aurora endpoints ends with '.com.cn'. Based on my experience the driver works in different regions except China becase with the same working config I got the following error there:
"Caused by: java.sql.SQLException: The clusterInstanceHostPattern configuration property is required when an IP address or custom domain is used to connect to a cluster that provides topology information. If you would instead like to connect without failover functionality, set the enableClusterAwareFailover configuration property to false."

Could you verify the chinese domains are recognized as custom domain please?

Regards

"drop-in" compatible for the MySQL Connector/J driver query interceptors

Describe the issue

After reading https://aws.amazon.com/about-aws/whats-new/2022/03/amazon-web-services-jdbc-driver-mysql-failover/ we decided it might be worth evaluating swapping to the AWS mysql driver.

Our application makes use of query interceptors, I see that you have shaded the mysql-jdbc code into the software.aws.rds.jdbc.mysql.shading package, generally I steer away from importing shaded packages but in this case I'm not sure how else it would work..

Index: sulake-common/src/main/java/com/sulake/common/jdbc/mysql/LoggingStatementInterceptor.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/sulake-common/src/main/java/com/sulake/common/jdbc/mysql/LoggingStatementInterceptor.java b/sulake-common/src/main/java/com/sulake/common/jdbc/mysql/LoggingStatementInterceptor.java
--- a/sulake-common/src/main/java/com/sulake/common/jdbc/mysql/LoggingStatementInterceptor.java	(revision f54e4c69eda64713855c47873010a588675da15d)
+++ b/sulake-common/src/main/java/com/sulake/common/jdbc/mysql/LoggingStatementInterceptor.java	(date 1646919173003)
@@ -3,15 +3,15 @@
  */
 package com.sulake.common.jdbc.mysql;
 
-import com.mysql.cj.AbstractPreparedQuery;
-import com.mysql.cj.MysqlConnection;
-import com.mysql.cj.Query;
-import com.mysql.cj.conf.PropertyKey;
-import com.mysql.cj.interceptors.QueryInterceptor;
-import com.mysql.cj.jdbc.JdbcStatement;
-import com.mysql.cj.log.Log;
-import com.mysql.cj.protocol.Resultset;
-import com.mysql.cj.protocol.ServerSession;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.AbstractPreparedQuery;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.MysqlConnection;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.Query;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.conf.PropertyKey;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.interceptors.QueryInterceptor;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.JdbcStatement;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.log.Log;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.Resultset;
+import software.aws.rds.jdbc.mysql.shading.com.mysql.cj.protocol.ServerSession;
 import com.sulake.common.metrics.MeasurementCollectingBeanInterceptor;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;

Unfortunately I see no mention of query interceptors in the repo yet, while this feels super hacky.. would this approach be supported by AWS? Or do you intend on adding interceptor support with your own "public" API in later versions?

Driver Version?

1.0.0

Java Version?

OS Version?

MySQL Version?

To Reproduce
Steps to reproduce the behaviour:

Expected behaviour
A clear and concise description of what you expected to happen.
And what actually happens

Logs
If possible MySQL logs surrounding the occurrence of the issue

Sources jar does not contain relocated classes

Describe the issue

The classes in the sources jar are not the same as the classes in the actual jar.
This is because package com.mysql is relocated to software.aws.rds.jdbc.mysql.shading.com.mysql during build, but not when sources are packaged.

Links

N/A

Please build and ship this library with source code

Hi. After using MariaDB connector and experimenting with the MySQL connector itself for our Aurora cluster, I now hope to find the best option in this project.
However, I dearly miss the option to also retrieve the source code for this library.
So please, build and ship this library with the option to fetch the source code via the IDE. In my case IntelliJ IDEA with Maven as build tool. Thanks!

`clusterInstanceHostPattern` is required with aurora db

Describe the issue
clusterInstanceHostPattern is required when using Aurora + software.aws.rds.jdbc.mysql.Driver
(acceptAwsProtocolOnly is also not working for me)

java.sql.SQLException: The clusterInstanceHostPattern configuration property is required when an IP address or custom domain is used to connect to a cluster that provides topology information. If you would instead like to connect without failover functionality, set the enableClusterAwareFailover configuration property to false.

Instance + software.aws.rds.jdbc.mysql.Driver or RDS + software.aws.rds.jdbc.mysql.Driver is working fine

Driver Version?
1.0.0
Java Version?
8
OS Version?
Ubuntu18
MySQL Version?
5.7
To Reproduce
Steps to reproduce the behaviour:

  • build.gradle
    implementation 'software.aws.rds:aws-mysql-jdbc:1.0.0'
  • application.yml
test-db:
    pool-name: test-db
    driverClassName: software.aws.rds.jdbc.mysql.Driver
    jdbc-url: jdbc:mysql:aws://localhost:25306/test-db
  • localhost:25306 is connected with Aurora DB through ssh tunnel
  • HikariCP Datasource

Expected behaviour

Logs

Make it AZ aware

Describe the feature

Sorry if this has already been addressed before. I couldn't find anything about it in the documentation so I'll ask the question here.

It would be nice if the connector was availability zone aware, meaning that the services using the connector would prefer to use a read replica that is running in the same AZ as itself, as this would drive down the costs for data traffic.

Use Case

I like to save money when I can.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

The AWS JDBC Driver for MySQL version used

v1.1.1

JDK version used

17

Operating System and version

Alpine 3.16

java.sql.SQLNonTransientConnectionException: Communications link failure during rollback(). Transaction resolution unknown

Describe the issue
A clear and concise description of what the issue is.

Driver Version?
aws-mysql-jdbc (version 1.0.0)

Java Version?

OS Version?

MySQL Version?
8.0.mysql_aurora.3.01.0

To Reproduce
Steps to reproduce the behaviour:

Expected behaviour
A clear and concise description of what you expected to happen.
And what actually happens

Logs
If possible MySQL logs surrounding the occurrence of the issue

GPLv2 license clarification

Please clarify the GPLv2 License: are we allowed to use this JDBC driver in commercial software that we run on Amazon servers? Additionally, when doing so, are we required to open-source our commercial software ?

I ask this question since there is a lot of confusion on the GPLv2 license change with the MySQL driver, and I was somewhat suprised to see the same license being used here. Many license scanning tools (and legal people) are red-flagging any library which uses the GPLv2 license.

Any clarification on this would be greatly appreciated

ClientPreparedQueryBindings IllegalArgumentException for large byte arrays

Describe the bug

For large byte arrays, the ByteArrayOutputStream constructor is called with a negative value at
due to the maximum possible value for an int, raising an IllegalArgumentException.
Sample stacktrace:

Caused by: java.lang.IllegalArgumentException: Negative initial size: -1818412943
at java.base/java.io.ByteArrayOutputStream.(Unknown Source)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.ClientPreparedQueryBindings.setBytes(ClientPreparedQueryBindings.java:219)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.ClientPreparedQueryBindings.setBytes(ClientPreparedQueryBindings.java:203)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ClientPreparedStatement.setBytes(ClientPreparedStatement.java:1505)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBytes(DelegatingPreparedStatement.java:138)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBytes(DelegatingPreparedStatement.java:138)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBytes(DelegatingPreparedStatement.java:138)
at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$3$1.doBind(BlobTypeDescriptor.java:113)
at org.hibernate.type.descriptor.sql.BlobTypeDescriptor$2$1.doBind(BlobTypeDescriptor.java:86)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:73)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:276)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:271)
at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:39)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:3073)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:3048)
at org.hibernate.persister.entity.AbstractEntityPersister$2.bindValues(AbstractEntityPersister.java:3271)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3279)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3885)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:330)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:123)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:185)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:128)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:55)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:774)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:760)

Expected Behavior

No exception is thrown

Current Behavior

An IllegalArgumentException is thrown at the ByteArrayOutputStream constructor

Reproduction Steps

Invoke ClientPreparedQueryBindings::setBytes with a large byte array

Possible Solution

No response

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.0

JDK version used

17

Operating System and version

Windows 10 enterprise

Using read-only endpoint, but all queries are going to the writer instance after a failover

Describe the issue
Using read-only endpoint, but all queries are going to the writer instance after a failover. I've also tried injecting disk congestion query to the new promoted primary, but it won't reroute the queries to read replica.

Driver Version?
1.0.0

Java Version?
openjdk 11.0.11

OS Version?
macOS 11.4

MySQL Version?
5.7.mysql_aurora.2.07.2

To Reproduce
In a AWS RDS cluster have two instances, one writer and and one reader. Use read-only endpoint for jdbc url and start sending read request and perform a failover on writer instance.

Expected behaviour
Once failover finishes queries should balance out or move to new read replicas.

After failover sometimes connections are readonly when should not.

Describe the issue
I am getting sometimes error The MySQL server is running with the --read-only option so it cannot execute this statement
after failover for connections that are using cluster endpoint

Driver Version?
1.0.0

Java Version?
Jdk 17

OS Version?

MySQL Version?
5.7.mysql_aurora.2.10.2

To Reproduce
I am using Hikari connection pool 3.4.5.
Sometimes after failover connections using writable endpoint are getting error that connection is read only. And situation will not solve over time.

Expected behaviour
Connection should be always writable.

Logs
If possible MySQL logs surrounding the occurrence of the issue

Support for HikariCP Connection pool - Question

Describe the issue
Do you support HikariCP , we are using mysql with HikariCP https://github.com/brettwooldridge/HikariCP and evaluating the Amazon Aurora MYSQL.

Driver Version?
0.1.0.

Java Version?
Open JDK 11

OS Version?
NA

MySQL Version?
5.7

To Reproduce
NA

Expected behaviour
NA

Logs
Failed to load driver class software.aws.rds.jdbc.mysql.Driver in either of HikariConfig class loader or Thread context classloader

use aws-mysql-jdbc 1.0.0 HikariCP 2.7.9 happened an ConcurrentModificationException, please help to check this question

Describe the issue
2022.5.16 UTC+8 ,prd issue use aws-mysql-jdbc 1.0.0 HikariCP 2.7.9 to resolve failover time too long question
2022.5.19 23:45 UTC+8 ,happen aurora failover,recove time about 30 second.
2022.5.20 12:00 UTC+8 ,happen other exception ConcurrentModificationException,The service has to be restart aurora to recover

Driver Version?
1.0.0

Java Version?
java-1.8-openjdk

OS Version?
aws cloud 4.14.209-160.339.amzn2.x86_64

MySQL Version?
5.7.12-log

To Reproduce
2022.5.16 UTC+8 ,prd issue use aws-mysql-jdbc 1.0.0 HikariCP 2.7.9 to resolve failover time too long question
2022.5.19 23:45 UTC+8 ,happen aurora failover,recove time about 30 second.
2022.5.20 12:00 UTC+8 ,happen other exception ConcurrentModificationException,The service has to be restart aurora to recover

Expected behaviour
expected use aws mysql jdbc driver 1.0.0 HikariCP 2.7.9 donot happen any exception

Logs
j.u.ConcurrentModificationException: null
at j.u.LinkedHashMap$LinkedHashIterator.remove(LinkedHashMap.java:732)
at s.a.r.j.m.s.c.m.c.u.ExpiringCache$1.removeEldestEntry(ExpiringCache.java:49)
at j.util.LinkedHashMap.afterNodeInsertion(LinkedHashMap.java:299)
at java.util.HashMap.putVal(HashMap.java:664)
at java.util.HashMap.put(HashMap.java:612)
at s.a.r.j.m.s.c.m.c.u.ExpiringCache.put(ExpiringCache.java:109)
at s.a.r.j.m.s.c.m.c.j.h.p.f.AuroraTopologyService.updateCache(AuroraTopologyService.java:388)
at s.a.r.j.m.s.c.m.c.j.h.p.f.AuroraTopologyService.getTopology(AuroraTopologyService.java:198)
at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.fetchTopology(FailoverConnectionPlugin.java:996)
at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.initializeTopology(FailoverConnectionPlugin.java:432)
at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.initFromHostPatternSetting(FailoverConnectionPlugin.java:965)
at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.initProxy(FailoverConnectionPlugin.java:973)
at s.a.r.j.m.s.c.m.c.j.h.p.f.FailoverConnectionPlugin.openInitialConnection(FailoverConnectionPlugin.java:217)
at s.a.r.j.m.s.c.m.c.j.h.p.ConnectionPluginManager.openInitialConnection(ConnectionPluginManager.java:146)
at s.a.r.j.m.s.c.m.c.j.h.ConnectionProxy.initPluginManager(ConnectionProxy.java:278)
at s.a.r.j.m.s.c.m.c.j.h.ConnectionProxy.(ConnectionProxy.java:99)
at s.a.r.j.m.s.c.m.c.j.h.ConnectionProxy.(ConnectionProxy.java:86)
at s.a.r.j.m.s.c.m.c.j.h.ConnectionProxy.(ConnectionProxy.java:74)
at s.a.r.j.m.s.c.m.c.j.h.ConnectionProxy.autodetectClusterAndCreateProxyInstance(ConnectionProxy.java:121)
at s.a.r.j.m.s.c.m.c.j.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
at c.z.h.u.DriverDataSource.getConnection(DriverDataSource.java:117)
at c.z.h.u.DriverDataSource.getConnection(DriverDataSource.java:123)
at c.z.h.pool.PoolBase.newConnection(PoolBase.java:365)
at c.z.h.pool.PoolBase.newPoolEntry(PoolBase.java:194)
at c.z.h.p.Hikar

Nullpointer exception with HikariCP 4.0.3

Describe the bug

We use aws mysql jdbc driver with Hikaricp 4.0.3 (spring boot 2.6.2)
Read-only datasource are set to aws mysql jdbc driver.
Null pointer exception occurs from this.threadContainer.getMonitor(node).stopMonitoring(context); when executing select query.

  @Override
  public void stopMonitoring(MonitorConnectionContext context) {
    if (context == null) {
      logger.logWarn(NullArgumentMessage.getMessage("context"));
      return;
    }

    // Any 1 node is enough to find the monitor containing the context
    // All nodes will map to the same monitor
    final String node = this.threadContainer.getNode(context.getNodeKeys());

    if (node == null) {
      logger.logWarn(Messages.getString("DefaultMonitorService.InvalidContext"));
      return;
    }

    ->> this.threadContainer.getMonitor(node).stopMonitoring(context);
  }

stack trace is below

java.lang.NullPointerException: null
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.DefaultMonitorService.stopMonitoring(DefaultMonitorService.java:130)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPlugin.execute(NodeMonitoringConnectionPlugin.java:182)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.execute(FailoverConnectionPlugin.java:248)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.ConnectionPluginManager.execute(ConnectionPluginManager.java:138)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy$JdbcInterfaceProxy.invoke(ConnectionProxy.java:320)\n\tat com.sun.proxy.$Proxy216.executeQuery(Unknown Source)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2322)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2075)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037)
at org.hibernate.loader.Loader.doQuery(Loader.java:956)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357)
at org.hibernate.loader.Loader.doList(Loader.java:2868)\n\tat org.hibernate.loader.Loader.doList(Loader.java:2850)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2682)
at org.hibernate.loader.Loader.list(Loader.java:2677)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:540)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:400)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1454)
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1649)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1617)
at org.hibernate.query.internal.AbstractProducedQuery.getSingleResult(AbstractProducedQuery.java:1665)
at com.querydsl.jpa.impl.AbstractJPAQuery.getSingleResult(AbstractJPAQuery.java:214)
at com.querydsl.jpa.impl.AbstractJPAQuery.fetchOne(AbstractJPAQuery.java:326)
at com.querydsl.core.support.FetchableQueryBase.fetchFirst(FetchableQueryBase.java:51)
....

java.lang.IllegalStateException: null
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.invoke(ConnectionProxy.java:207)
at com.sun.proxy.$Proxy113.clearWarnings(Unknown Source)
at com.zaxxer.hikari.pool.HikariProxyConnection.clearWarnings(HikariProxyConnection.java)
at jdk.internal.reflect.GeneratedMethodAccessor98.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:378)\n\tat com.sun.proxy.$Proxy130.clearWarnings(Unknown Source)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.handleAndClearWarnings(SqlExceptionHelper.java:299)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.logAndClearWarnings(SqlExceptionHelper.java:269)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.releaseConnection(LogicalConnectionManagedImpl.java:215)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.close(LogicalConnectionManagedImpl.java:261)
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:175)
at org.hibernate.internal.AbstractSharedSessionContract.close(AbstractSharedSessionContract.java:374)
at org.hibernate.internal.SessionImpl.closeWithoutOpenChecks(SessionImpl.java:417)
at org.hibernate.internal.SessionImpl.close(SessionImpl.java:402)
at org.springframework.orm.jpa.EntityManagerFactoryUtils.closeEntityManager(EntityManagerFactoryUtils.java:427)
at org.springframework.orm.jpa.JpaTransactionManager.doCleanupAfterCompletion(JpaTransactionManager.java:650)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:992)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:790)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:711)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:654)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:407)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
....
....
Caused by: java.lang.NullPointerException: null
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.DefaultMonitorService.stopMonitoringForAllConnections(DefaultMonitorService.java:141)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPlugin.checkIfChanged(NodeMonitoringConnectionPlugin.java:289)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPlugin.execute(NodeMonitoringConnectionPlugin.java:167)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.execute(FailoverConnectionPlugin.java:248)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.ConnectionPluginManager.execute(ConnectionPluginManager.java:138)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.invoke(ConnectionProxy.java:193)\n\t... 85 common frames omitted

Expected Behavior

No error occurs.

Current Behavior

Error occurs irregularly (especially starting point to test).
There is another something strange that slave connections are moved to master instance increasingly.
Below is datasource property:

  datasource:
    my-service:
      master:
        driver-class-name: com.mysql.cj.jdbc.Driver
        jdbc-url: jdbc:mysql://{identifier}.cluster-{XYZ}.ap-northeast-2.rds.amazonaws.com:3306/{db_name}?zeroDateTimeBehavior=convertToNull&useUnicode=yes&characterEncoding=UTF-8&connectTimeout=2000&serverTimezone=Asia/Seoul&useTimezone=true&useSSL=false
        username: user
        password: pass
        maximum-pool-size: 100
      slave:
        driver-class-name: software.aws.rds.jdbc.mysql.Driver
        jdbc-url: jdbc:mysql:aws://{identifier}.cluster-ro-{XYZ}.ap-northeast-2.rds.amazonaws.com:3306/{db_name}?zeroDateTimeBehavior=CONVERT_TO_NULL&useUnicode=yes&characterEncoding=UTF-8&connectTimeout=2000&serverTimezone=Asia/Seoul&useTimezone=true&useSSL=false
        username: user
        password: pass
        maximum-pool-size: 100

But when test started, connections moved to master instance like below
스크린샷 2022-08-10 오후 4 11 51

After testing finished (no query), connections are divided correctly.

Reproduction Steps

Burst select query about 7~8000 request / second to AWS Arurora MySQL RDS cluster(1 master, 1 slave) with aws mysql jdbc driver datasource using spring boot 2.6.2.

Possible Solution

No response

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.0

JDK version used

1.8

Operating System and version

amazon linux2 / Debian GNU/Linux 11 (docker container)

Several re-connection issues with Aurora v2

Describe the bug

After a failover, some connections are invalid:

  • they are connected to the replica instead of the writer
  • the failover is disabled

Expected Behavior

Connections to writer should reconnect to the new writer, and the failover should still be enabled

Current Behavior

After a failover, some connections are invalid:

  • they are connected to the replica instead of the writer
  • the failover is disabled

Reproduction Steps

It happens with multiple connections only, because some go through the failover process, which updates the topology in the shared cache.
Then other connections are using incorrectly the new topology to update actual connection.

Possible Solution

PR: #302

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.1

JDK version used

11

Operating System and version

Alpine 3.16

Plugins package names in connectionPluginFactories property of connectionUrl

Describe the issue

I'm using
implementation group: 'software.aws.rds', name: 'aws-mysql-jdbc', version: '1.1.1'

Its an issue in 1.1.0 version of the driver as well.

README recommends following plugin factories with their package names as 'com.mysql.cj.jdbc.ha.plugins'
com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPluginFactory, com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory
com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPluginFactory

But when I use them, I get following error during application start
Unable to load connection plugin factory 'com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPluginFactory
Unable to load connection plugin factory 'com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory
Unable to load connection plugin factory 'com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPluginFactory

To make my application work, I used 'software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.' package
connectionPluginFactories=
software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPluginFactory,
software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPluginFactory,
software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.AWSSecretsManagerPluginFactory

Can you please recommend the right package names for plugins and update README accordingly?
This is very much needed for my project documentation.

Links

(https://github.com/awslabs/aws-mysql-jdbc/#readme)

How do I configure logging levels?

  • [ ] bug report
  • [ x ] feature request

Describe the issue
This library is logging quite a lot. I see log lines with level TRACE. I would like to see only INFO level log lines and up

I'm using Spring Boot and Hikari. The driver seems to do custom logging outside the usual logging framework? How do I configure the log levels?

Driver Version?
0.1.0

Build failure - 0.2.0 & OpenJDK Runtime Environment Corretto-11.0.8.10.1 (build 11.0.8+10-LTS)

Describe the issue
A clear and concise description of what the issue is.

I'm attempting to build & compile locally using Corretto 11.0.8 so that I can use the jdbc driver on an application server that will only support 11.0.8 and BELOW JDK.

Command:
gradle build -x test results in a build failure. Specifics:
FAILURE: Build failed with an exception.

  • What went wrong:
    Could not determine the dependencies of task ':shadowJar'.

Could not resolve all dependencies for configuration ':runtimeClasspath'.
Could not resolve sun-jaxb:jaxb-api:2.1.9.
Required by:
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss:jbossxb:2.0.3.GA
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.jbossas:jboss-as-system:6.1.0.Final > org.jboss.aop:jboss-aop-deployers:2.2.2.GA > org.jboss.aop:jboss-aop-asintegration-mc:2.2.2.GA > org.jboss.classpool:jboss-classpool-jbosscl:1.0.0.Alpha6
> Could not resolve sun-jaxb:jaxb-api:2.1.9.
> Could not get resource 'https://repository.jboss.org/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.pom'.
> Could not GET 'https://repository.jboss.org/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.pom'.
> Connection reset
Could not resolve oswego-concurrent:concurrent:1.3.4-jboss-update1.
Required by:
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.jbossas:jboss-as-server:6.1.0.Final
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.jbossas:jboss-as-server:6.1.0.Final > org.jboss.jbossas:jboss-as-deployment:6.1.0.Final
> Could not resolve oswego-concurrent:concurrent:1.3.4-jboss-update1.
> Could not get resource 'https://repository.jboss.org/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.pom'.
> Could not GET 'https://repository.jboss.org/oswego-concurrent/concurrent/1.3.4-jboss-update1/concurrent-1.3.4-jboss-update1.pom'.
> Connection reset
Could not resolve gnu-getopt:getopt:1.0.13.
Required by:
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.jbossas:jboss-as-server:6.1.0.Final
> Could not resolve gnu-getopt:getopt:1.0.13.
> Could not get resource 'https://repository.jboss.org/gnu-getopt/getopt/1.0.13/getopt-1.0.13.pom'.
> Could not GET 'https://repository.jboss.org/gnu-getopt/getopt/1.0.13/getopt-1.0.13.pom'.
> Connection reset
Could not resolve sun-jaxb:jaxb-api:2.1.9.
Required by:
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.man:jboss-managed:2.1.1.SP2
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.metadata:jboss-metadata-common:2.0.0.Alpha25
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.jbossas:jboss-as-server:6.1.0.Final > org.jboss.jpa:jboss-jpa-deployers:1.0.2-alpha-4 > org.jboss.metadata:jboss-metadata:1.0.0.CR17
> Could not resolve sun-jaxb:jaxb-api:2.1.9.
> Could not get resource 'https://repository.jboss.org/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.pom'.
> Could not GET 'https://repository.jboss.org/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.pom'.
> Connection reset
Could not resolve org.apache:xmlsec:1.4.3.
Required by:
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.jbossas:jboss-as-server:6.1.0.Final > org.jboss.jbossas:jboss-as-security:6.1.0.Final
> Could not resolve org.apache:xmlsec:1.4.3.
> Could not get resource 'https://repository.jboss.org/org/apache/xmlsec/1.4.3/xmlsec-1.4.3.pom'.
> Could not GET 'https://repository.jboss.org/org/apache/xmlsec/1.4.3/xmlsec-1.4.3.pom'.
> Connection reset
Could not resolve gnu-getopt:getopt:1.0.13.
Required by:
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.metadata:jboss-metadata-common:2.0.0.Alpha25 > org.jboss.ws:jbossws-spi:1.4.1.SP1
> Could not resolve gnu-getopt:getopt:1.0.13.
> Could not get resource 'https://repository.jboss.org/gnu-getopt/getopt/1.0.13/getopt-1.0.13.pom'.
> Could not GET 'https://repository.jboss.org/gnu-getopt/getopt/1.0.13/getopt-1.0.13.pom'.
> Connection reset
Could not resolve sun-jaxb:jaxb-api:2.1.9.
Required by:
project : > org.jboss.jbossas:jboss-as-connector:6.1.0.Final > org.jboss.jbossas:jboss-as-system:6.1.0.Final > org.jboss.profileservice:jboss-profileservice-core:0.2.2 > org.jboss.profileservice:jboss-profileservice-persistence:0.2.2
> Could not resolve sun-jaxb:jaxb-api:2.1.9.
> Could not get resource 'https://repository.jboss.org/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.pom'.
> Could not GET 'https://repository.jboss.org/sun-jaxb/jaxb-api/2.1.9/jaxb-api-2.1.9.pom'.
> Connection reset

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 6m 2s

Driver Version?
0.2.0

Java Version?
OpenJDK Runtime Environment Corretto-11.0.8.10.1 (build 11.0.8+10-LTS)

OS Version?
Mac OS Catalina 10.15.7

MySQL Version?
5.6

ResultSet#getObject() on Timestamp does not return java.sql.Timestamp nor does the object display in the correct format

Describe the bug

https://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.html#getObject(int) indicates that The type of the Java object will be the default Java object type corresponding to the column's SQL type, following the mapping for built-in types specified in the JDBC specification. Not exactly sure where the spec is but https://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/mapping.html and https://docs.oracle.com/javadb/10.10.1.2/ref/rrefjdbc20377.html seem to be indicating that a java.sql.Timestamp is expected. Furthermore, from the MySQL docs https://dev.mysql.com/doc/refman/8.0/en/datetime.html, the timestamp format should be YYYY-MM-DD hh:mm:ss[.fraction].

The AWS Aurora MySQL driver returns a java.time.LocalDateTime and has a T in the formatting that shouldn't be there.

Expected Behavior

getObject on a Timestamp field should return a java.sql.Timestamp without a T in it like 2022-11-23 04:20:34.0

Current Behavior

getObject on a Timestamp field returns a java.time.LocalDateTime whose format has a T in it, like 2022-11-23T04:20:34

Reproduction Steps

Create a table with a DATETIME and add a value CREATE TABLE TT (val DATETIME); INSERT INTO TT VALUES (NOW());

Put both the MySQL and AWS MySQL drivers on the classpath and use the following code.

software.aws.rds.jdbc.mysql.Driver.setAcceptAwsProtocolOnly(true);

    try (
        Connection conn = DriverManager.getConnection(jdbcUrl, userName, password);
        Statement statement = conn.createStatement();
        ResultSet resultSet = statement.executeQuery("SELECT * FROM TT;");
    ) {
      while (resultSet.next()) {
        Object firstVal = resultSet.getObject(1);
      }
    }

Using a MySQL JDBC URL, you'll get the expected behavior.

Using an AWS Aurora MySQL JDBC URL, you'll get the unexpected behavior.

Possible Solution

Use Timestamp.valueOf(LocalDateTime dateTime)to convert, but it doesn't seem to be quite so simple.

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.1

JDK version used

1.8

Operating System and version

MacOS Monterey 12.6.1

First test issue

**Congrats on the release! **

Expected behaviour
Just filing a 1st issue as a test

Logs
Looking forward to the GA

Quartz schedulers failing with driver version 1.1.0

Describe the bug

We were trying to switch from MariaDB driver to AWS JDBC driver but the quartz schedulers in our applications are failing with below error I did not observe this issue if I use version 1.0.0

ERROR [] [scheduler_QuartzSchedulerThread] [ErrorLogger] An error occurred whi
le scanning for the next triggers to fire. tag=
org.quartz.JobPersistenceException: Couldn't acquire next trigger: Parameter index out of range (1 > number of
parameters, which is 0).
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2923)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2805)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2803)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3864)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287)
Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:1
29)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:9
7)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:8
9)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:6
3)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ClientPreparedStatement.checkBounds(ClientPreparedStat
ement.java:1396)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ClientPreparedStatement.getCoreParameterIndex(ClientPr
eparedStatement.java:1409)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ClientPreparedStatement.setString(ClientPreparedStatem
ent.java:1776)
at jdk.internal.reflect.GeneratedMethodAccessor39.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy$JdbcInterfaceProxy.lambda$invoke$0(
ConnectionProxy.java:323)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.DefaultConnectionPlugin.execute(DefaultConn
ectionPlugin.java:80)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.NodeMonitoringConnectionPlugin.execute(Node
MonitoringConnectionPlugin.java:178)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.execute(F
ailoverConnectionPlugin.java:248)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.ConnectionPluginManager.execute(ConnectionP
luginManager.java:138)
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy$JdbcInterfaceProxy.invoke(Connectio
nProxy.java:320)
at com.sun.proxy.$Proxy98.setString(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setString(NewProxyPreparedStatement.java:618)
at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.selectTriggerToAcquire(StdJDBCDelegate.java:2610)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTrigger(JobStoreSupport.java:2844)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2805)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$41.execute(JobStoreSupport.java:2803)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInNonManagedTXLock(JobStoreSupport.java:3864)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.acquireNextTriggers(JobStoreSupport.java:2802)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:287)

Expected Behavior

Quartz scheduler to work and make queries to the database.

Current Behavior

   Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
   at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:1

Reproduction Steps

https://examples.javacodegeeks.com/enterprise-java/quartz/quartz-scheduler-example/

Possible Solution

No response

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.0.0

JDK version used

java 11.0.3 2019-04-16 LTS

Operating System and version

CentOS 7

performance between AWS JDBC Connector and MySQL JDBC Connecto

I'm submitting a performance concern...

Describe the issue

using MySQL JDBC Connector - (https://dev.mysql.com/downloads/connector/j/)

the insert takes 23 sec for inserting 1,000,000 rows

on the otherhand

using AWS JDBC Connector - (https://awslabs.github.io/aws-mysql-jdbc/)

the same insert takes 39s for inserting 1,000,000 rows

A clear and concise description of what the issue is.

Driver Version? aws-mysql-jdbc-1.0.0.jar

MySQL Version? aurora mysql 3

To Reproduce
run the following insert via java using the above drivers

"INSERT INTO test.table_row (A_COL, B_COL, C_COL) VALUES (?,?,?)"

Expected behaviour
the insert time should be the same.

Distinct ClientPreparedStatement objects incorrectly have same hashCode and match with equals()

Describe the bug

Distinct ClientPreparedStatements sharing a ConnectionProxy will all use the hashCode() and equals() of the ConnectionProxy and therefore will all have the same hash code and be equals via the equals() call.

This is a problem not only because fundamentally the objects are different so they should have different hash codes and not be equal, but also because when using the AWS Aurora MySQL driver with Hibernate 5, the ClientPreparedStatements will be registered in ResourceRegistryStandardImpl here https://github.com/hibernate/hibernate-orm/blob/main/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/ResourceRegistryStandardImpl.java#L87 . This code will throw an exception when the Statement (key) was already registered. Multiple different statements with the same hashCode() that are equal via the equals() will cause this problem.

Expected Behavior

Multiple ClientPreparedStatements using the same ConnectionProxy should have different hash code values and not be equal via equals()

Current Behavior

Normally, Hibernate code will throw an exception when the Statement (key) was already registered. It detects this by seeing if the key already exists in its map. Using the AWS Aurora MySQL driver, multiple different statements with the same hashCode() that are equal via the equals() will cause a "JDBC Statement already registered" even if the Statements are not the same.

Reproduction Steps

Using the same Hibernate Session, call prepareQueryStatement() with two different Statements that use different SQL queries.

Expected: Successful registration of the two Statements

Actual: First ClientPreparedStatement registers successfully but the second registration has an HibernateException thrown from ResourceRegistryStandardImpl with message JDBC Statement already registered

Possible Solution

One possible solution is to simply not let the proxy directly execute equals() and hashCode() and instead defer to the underlying Statement.

src/main/user-impl/java/com/mysql/cj/jdbc/ha/ConnectionProxy.java implements invoke() (https://github.com/awslabs/aws-mysql-jdbc/blob/main/src/main/user-impl/java/com/mysql/cj/jdbc/ha/ConnectionProxy.java#L312) which will detect if the method is equals or hashCode (https://github.com/awslabs/aws-mysql-jdbc/blob/main/src/main/user-impl/java/com/mysql/cj/jdbc/ha/ConnectionProxy.java#L296) and if so, it uses the implementation of the ConnectionProxy instead of the implementation of the underlying object (https://github.com/awslabs/aws-mysql-jdbc/blob/main/src/main/user-impl/java/com/mysql/cj/jdbc/ha/ConnectionProxy.java#L267). In this case, the underlying object is the ClientPreparedStatement. Two different ClientPreparedStatement objects that share the same ConnectionProxy will be equal because they share the same hash code and equals() will evaluate to true.

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.1 (and 1.1.0)

JDK version used

1.8

Operating System and version

MacOS Monterey 12.3.1

Support AWS SDK for Java 2.x for AWS IAM Database Authentication

  • bug report
  • feature request

Using AWS IAM Database Authentication requires currently the following maven dependency:

<dependency>
	<groupId>com.amazonaws</groupId>
	<artifactId>aws-java-sdk-rds</artifactId>
</dependency>

I'd like to use it based on the newer AWS SDK for Java 2.x:

<dependency>
	<groupId>software.amazon.awssdk</groupId>
	<artifactId>rds</artifactId>
</dependency>

While it is possible to mix the old and new java SDK in the same application, the older sdk does not have the sso library that has been added to the new awssdk.
Because of that limitation it is currently not possible to combine SSO and AWS IAM Database Authentication using this driver. In my case this means I cannot use AWS IAM Database Authentication in my development environment where I use SSO to manage AWS credentials.

Would you be interested in adding this feature?

GPLv2 license clarification

Please clarify the GPLv2 License: are we allowed to use this JDBC driver in commercial software that we run on Amazon servers? Additionally, when doing so, are we required to open-source our commercial software ?

I ask this question since there is a lot of confusion on the GPLv2 license change with the MySQL driver, and I was somewhat surprised to see the same license being used here. Many license scanning tools (and legal people) are red-flagging any library which uses the GPLv2 license.

Any clarification on this would be greatly appreciated

Why this project source code license use GPL v2 not Apache 2.0

Describe the issue
I found this driver by this blog(https://awslabs.github.io/aws-mysql-jdbc/)

I want to use this driver to improve the robustness of our application to failover, so I paid attention to this project

Then I am confused about the source code license, I use AWS aurora Cluster , I think most users who want to use this driver also use Aurora Cluster

This license is not friendly to commercial application,is it appropriate which mainly used by users who use Aurora Cluster (Commercial Cloud Paas )

I respect the work of the open source community, but I want to know the answer about this question.
The license will affect whether I can use the driver

Driver Version?
1.0.0
Java Version?

OS Version?

MySQL Version?
Aurora
To Reproduce
Steps to reproduce the behaviour:

Expected behaviour
A clear and concise description of what you expected to happen.
And what actually happens

Logs
If possible MySQL logs surrounding the occurrence of the issue

DatabaseMetaData#getDriverVersion is reporting a SNAPSHOT version

Describe the bug

Official v1.1.2 release of the driver should report a non-snapshot version via DatabaseMetaData#getDriverVersion but instead reports a snapshot version.

Expected Behavior

Driver version should report a non snapshot version like aws-mysql-connector-java-1.1.2

Current Behavior

Driver version reports a snapshot version like aws-mysql-connector-java-1.1.2-SNAPSHOT (Revision: d85fd009cb21f60b0a9316b94b05628633e261f7)

image

Reproduction Steps

With a valid aurora mysql instance and credentials,

Connection conn = DriverManager.getConnection(jdbcUrl, userName, password);
System.out.println(conn.getMetaData().getDriverVersion());

with a gradle build file using maven central and implementation 'software.aws.rds:aws-mysql-jdbc:1.1.2'

Possible Solution

Possible problem with release process?

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.2

JDK version used

1.8

Operating System and version

MacOS Monterey 12.6.1

Test #2

Describe the issue
There is no issue. Testing the notifications for rissues.

Expected behaviour
This will be received by the AWS alias for the project.

clusterInstanceHostPattern should be optional for custom host names

Describe the feature

When a custom host name is used as the host in the JDBC URL, then opaquely named clusterInstanceHostPattern paramater must be added. This should have a sensible default instead.

Use Case

It's very common to have a custom domain ( dev.rds.mydomain.com) as a CNAME to an RDS cluster (dev-cluster.cluster-cmdXXXXXX.eu-west-2.rds.amazonaws.com.)

With the MySQL JDBC driver this Just Works. With the AWS driver it's required to also clusterInstanceHostPattern to inform the driver of :

  • RDS account id (cmdXXXXXX)
  • RDS region (eu-west-2)
    By adding to the JDBC URL ?clusterInstanceHostPattern=?.cmdXXXXXX.eu-west-2.rds.amazonaws.com

Which although clearly documented is a barrier to adoption because 'just' swapping in the JDBC URL and .jar does not work as expected.

Proposed Solution

AWS JDBC driver should be able to look up the current account and region and generate the correct internals details for itself, either from information schemas in the database itself or some other back channel.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

The AWS JDBC Driver for MySQL version used

1.1.0

JDK version used

openjdk version "11.0.7" 2020-04-14

Operating System and version

Ubuntu 22.04.1 LTS

Can I use load balancing to reader instance for read-only transactions, as the mariadb connector supports?

Describe the issue
Can I use load balancing to reader instance for read-only transactions, as the mariadb connector supports?
Primary/replica connection selection

I tried to load balance by implementing AbstractRoutingDataSource, but it didn't seem to work.
Please let me know if there is a way to make read-only transactions only processed by the reader instances.

Driver Version?
software.aws.rds:aws-mysql-jdbc:1.0.0

Java Version?
8 or 11

OS Version?
amazon linux used as the worker node of eks

MySQL Version?
5.7.mysql_aurora.2.09.2

To Reproduce
Steps to reproduce the behaviour:

  1. Add implementation 'software.aws.rds:aws-mysql-jdbc:1.0.0' to build.gradle.
  2. Create 2 datasources for writer/reader. (both set the connection pool to 50)
  3. Implement AbstractRoutingDataSource to route transactions.
  4. There are 4 pods and the application runs in each pod.
  5. Run some workloads.

Expected behaviour
Primary/replica connection selection: read-only transactions must be sent to the reader instances.

Logs

  • test-db-instance-1: Writer instance
  • test-db-instance-2: Reader instance

General log of query with @Transactional(readOnly = true)

Timestamp Message Log stream name
 2022-03-29T15:45:43.648+09:00 2022-03-29T06:45:43.648313Z 341 Query SELECT test_type FRO ... test-db-instance-1
 2022-03-29T15:46:12.237+09:00 2022-03-29T06:46:12.237192Z 341 Query SELECT test_type FRO ... test-db-instance-2
 2022-03-29T15:46:44.359+09:00 2022-03-29T06:46:44.359068Z 341 Query SELECT test_type FRO ... test-db-instance-1
 2022-03-29T15:47:01.764+09:00 2022-03-29T06:47:01.764842Z 341 Query SELECT test_type FRO ... test-db-instance-1
... ... ...

use aws mysql jdbc driver 1.0.0 HikariCP 3.4.5 only write failover time too long than HikariCP 2.7.5

Describe the issue
use aws mysql jdbc driver HikariCP 3.4.5 only write failover time too long than HikariCP 2.7.5.

Driver Version?
1.0.0

Java Version?
java-1.8-openjdk

OS Version?
aws cloud 4.14.209-160.339.amzn2.x86_64

MySQL Version?
5.7.12-log

To Reproduce
use aws mysql jdbc driver 1.0.0 HikariCP 3.4.5,insert data and then aurora execute failover ,check recover time
use aws mysql jdbc driver 1.0.0 HikariCP 2.7.5,insert data and then aurora execute failover ,check recover time
in the end compare two result

Expected behaviour
expected use aws mysql jdbc driver 1.0.0 HikariCP 3.4.5 when happen failover , recover time can be in 30s

Logs
if not recover , when insert data , it will happen an read only exception

Aurora - Support for Writer & Reader cluster in the jdbc URL

When the writer & reader cluster URL is provided, the driver failed with a "Communications link failure" error message. the JDBC url is of format - jdbc:mysql:aws://<Write Cluster URL>:<port>;<Read cluster URL>:<PORT>/<DB name>?useSSL=true&requireSSL=true&sslrootcert=rds-combined-ca-bundle.pem . Is the case the driver accepts one type of URL and the client needs to maintain a separate write & read connection pool? MariaDB driver with aurora prefix
is used to supporting this format and balances connections between write & read replicas. What is the suggested approach to implementing the same in the aws JDBC driver?

BTW, the same url works if the writer cluster url or the reader cludetr url is provided alone.

aws-mysql-jdbc should be tollerant to JDBC URL params without value like disableMariaDbDriver

Describe the feature

Considering the issue:

I would ask you if aws-mysql-jdbc driver could be tollerant to JDBC url parameter like disableMariaDbDriver. MySQL driver is actually tollerant to this type of parameters.

Use Case

I'm porting a legacy app running on Tomcat 9 to EKS and RDS Aurora. This app have both mysql-connector-java-8.0.25.jar and mariadb-java-client-2.7.2.jar in its classpath: both the drivers are needed because our app could connect to multiple DBMS at the same time.

The version of MariaDB driver we use supports the parameter disableMariaDbDriver used like:

jdbc:mysql://localhost:3306/mydb?disableMariaDbDriver

This let the MariaDB driver to ignore this kind of URL, delegating the connection to the MySQL driver.

During the porting we replaced our MySQL driver with aws-mysql-jdbc and we fixed the JDBC URL like:

jdbc:mysql:aws://myrds:3306/mydb?disableMariaDbDriver

But this generate the following stack trace during connect opening:

java.lang.NullPointerException: null
        at java.util.Hashtable.put(Hashtable.java:460) ~[?:1.8.0_265]
        at java.util.Hashtable.putAll(Hashtable.java:524) ~[?:1.8.0_265]
        at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.conf.ConnectionUrl.getConnectionArgumentsAsProperties(ConnectionUrl.java:780) ~[aws-mysql-jdbc-1.1.0.jar:?]
        at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.autodetectClusterAndCreateProxyInstance(ConnectionProxy.java:122) ~[aws-mysql-jdbc-1.1.0.jar:?]
        at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221) ~[aws-mysql-jdbc-1.1.0.jar:?]
        at org.apache.tomcat.dbcp.dbcp2.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:52) ~[tomcat-dbcp.jar:9.0.60]    
        at org.apache.tomcat.dbcp.dbcp2.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:415) ~[tomcat-dbcp.jar:9.0.60]     
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.validateConnectionFactory(BasicDataSource.java:111) ~[tomcat-dbcp.jar:9.0.60]
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:649) ~[tomcat-dbcp.jar:9.0.60]    
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:532) ~[tomcat-dbcp.jar:9.0.60]
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.lambda$getConnection$0(BasicDataSource.java:720) ~[tomcat-dbcp.jar:9.0.60]
        at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_265]
        at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:722) ~[tomcat-dbcp.jar:9.0.60]

While the MySQL driver is tollerant to unknown, valueless parameters (at least the version we use).

Proposed Solution

To replicate in some way the params management of the official MySQL driver.

Other Information

A simple workaround for this is to add a dummy value to this parameter like:

jdbc:mysql:aws://myrds:3306/mydb?disableMariaDbDriver=whatever

To replicate the case you can create an empty dir, put in the aws-mysql-jdbc-1.1.0.jar and a Main.java with the following content:

import java.sql.Connection;      
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;   
import java.sql.SQLException;    

public class Main {

        private static final String CONNECTION_STRING = "jdbc:mysql:aws://myrds:3306?mydb";    
        private static final String USER = "admin";
        private static final String PASSWORD = "very-long-password";

        public static void main(String[] args) throws SQLException {

                try (final Connection conn = DriverManager.getConnection(CONNECTION_STRING, USER, PASSWORD)) {
                        DatabaseMetaData metaData = conn.getMetaData();

                        String url = metaData.getURL();

                        System.out.println(url);
                }
        }

}

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

The AWS JDBC Driver for MySQL version used

1.1.0

JDK version used

openjdk version "1.8.0_265" OpenJDK Runtime Environment (build 1.8.0_265-b01) OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)

Operating System and version

Debian 10.6 from openjdk:8 Docker image

JTA Transactions fail with XAER_RMFAIL

Describe the bug

We have the issue that some of our JTA transactions fail with the Exception below.

The same transactions work nicely with the vanilla MySQL driver (8.0.29+).

This happened with v1.1.0.

Caused by: java.sql.SQLException: XAER_RMFAIL: The command cannot be executed when global transaction is in the  PREPARED state
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1201)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.AuroraTopologyService.queryForTopology(AuroraTopologyService.java:231)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.AuroraTopologyService.getTopology(AuroraTopologyService.java:200)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.updateTopologyAndConnectIfNeeded(FailoverConnectionPlugin.java:714)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.execute(FailoverConnectionPlugin.java:247)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.ConnectionPluginManager.execute(ConnectionPluginManager.java:138)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy$JdbcInterfaceProxy.invoke(ConnectionProxy.java:320)
		at com.awssql//com.sun.proxy.$Proxy265.getResultSet(Unknown Source)
		at com.awssql//software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.MysqlXAConnection.dispatchCommand(MysqlXAConnection.java:325)
		... 45 more

Expected Behavior

JTA transactions work the same as with the latest vanilla MySQL drivers.

Current Behavior

Transaction rollback

Reproduction Steps

This happens in specific scenarios with no trivial way to recreate this.

Possible Solution

I suppose this may be related to the rather old MySQL base version used for the AWS Driver.

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.0

JDK version used

JDK 11

Operating System and version

AL2 (hosted in EKS)

invoke isClosed() method throw Exception

Describe the issue
long time not to use connection, mysql server side will disconnect it, when druid invoke isClosed() to check connection state, aws jdbc driver throw exception, how error origin mysql driver just return false.

Driver Version?
1.0.0
Java Version?
JDK8
OS Version?
Mac OSX
MySQL Version?
5.7
To Reproduce
Steps to reproduce the behaviour:

  1. set mysql server wait_timeout value to low value, eg:60
  2. use druid to create mysql conn
  3. wait to timeout
  4. use druid to execute sql
  5. got exception

Expected behaviour
when durid invoke isClosed() method to check conn state, just return true or false. if connection can't use druid will destroy backend.

Logs
image

`### The error occurred while executing a query

Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: The active SQL connection has changed due to a connection failure. Please re-configure session state if required.] with root cause

java.sql.SQLException: The active SQL connection has changed due to a connection failure. Please re-configure session state if required.
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.failover(FailoverConnectionPlugin.java:500) ~[aws-mysql-jdbc-1.0.0.jar:na]
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.pickNewConnection(FailoverConnectionPlugin.java:599) ~[aws-mysql-jdbc-1.0.0.jar:na]
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.dealWithOriginalException(FailoverConnectionPlugin.java:834) ~[aws-mysql-jdbc-1.0.0.jar:na]
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.failover.FailoverConnectionPlugin.execute(FailoverConnectionPlugin.java:248) ~[aws-mysql-jdbc-1.0.0.jar:na]
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.plugins.ConnectionPluginManager.execute(ConnectionPluginManager.java:133) ~[aws-mysql-jdbc-1.0.0.jar:na]
at software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.ha.ConnectionProxy.invoke(ConnectionProxy.java:188) ~[aws-mysql-jdbc-1.0.0.jar:na]
at com.sun.proxy.$Proxy56.isClosed(Unknown Source) ~[na:na]
at com.alibaba.druid.filter.FilterChainImpl.connection_isClosed(FilterChainImpl.java:452) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterAdapter.connection_isClosed(FilterAdapter.java:889) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterChainImpl.connection_isClosed(FilterChainImpl.java:448) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterAdapter.connection_isClosed(FilterAdapter.java:889) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterChainImpl.connection_isClosed(FilterChainImpl.java:448) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterAdapter.connection_isClosed(FilterAdapter.java:889) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterChainImpl.connection_isClosed(FilterChainImpl.java:448) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.isClosed(ConnectionProxyImpl.java:283) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:1450) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5059) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterAdapter.dataSource_getConnection(FilterAdapter.java:2756) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5055) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.logging.LogFilter.dataSource_getConnection(LogFilter.java:917) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5055) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.stat.StatFilter.dataSource_getConnection(StatFilter.java:726) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:5055) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1405) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1397) ~[druid-1.2.8.jar:1.2.8]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:100) ~[druid-1.2.8.jar:1.2.8]
at org.springframework.jdbc.datasource.DataSourceUtils.fetchConnection(DataSourceUtils.java:159) ~[spring-jdbc-5.3.18.jar:5.3.18]
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:117) ~[spring-jdbc-5.3.18.jar:5.3.18]
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80) ~[spring-jdbc-5.3.18.jar:5.3.18]
at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:80) ~[mybatis-spring-2.0.7.jar:2.0.7]
at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:67) ~[mybatis-spring-2.0.7.jar:2.0.7]
at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:337) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:89) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) ~[mybatis-3.5.9.jar:3.5.9]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ~[mybatis-spring-2.0.7.jar:2.0.7]
at com.sun.proxy.$Proxy61.selectList(Unknown Source) ~[na:na]
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) ~[mybatis-spring-2.0.7.jar:2.0.7]
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145) ~[mybatis-3.5.9.jar:3.5.9]
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) ~[mybatis-3.5.9.jar:3.5.9]
at com.sun.proxy.$Proxy62.queryDisputeInfoList(Unknown Source) ~[na:na]
at com.example.spring.boot.demo.DemoService.test(DemoService.java:17) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.18.jar:5.3.18]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.18.jar:5.3.18]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.60.jar:4.0.FR]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.18.jar:5.3.18]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.60.jar:4.0.FR]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.18.jar:5.3.18]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.18.jar:5.3.18]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.60.jar:9.0.60]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.60.jar:9.0.60]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_162]`

AWS Mysql driver does not work if Route53 entry used instead of cluster endpoint

Describe the bug

Depending on how you look at the problem, it could be a bug, limitation or documentation missing.

In some of our environments we were using Route53 records from a past database migration (RDS proxies were not available at that time). So when we switched to use the AWS Mysql driver for autoscaling, we've noticed that in all environments using Route53 records for the writer & ro endpoints, the driver reported connection failure while working correctly on all other environments.

Expected Behavior

The standard Mysql driver allows this behaviour but it's debatable if in a cloud environment it should be preferred since Route53 records could potentially cache removed read replicas.

If we are to stick to the behaviour in the default driver, the current behaviour is unexpected behaviour.
If this is considered an antipattern, we should update the documentation to warn around potential connectivity issues if Route53 records are used

Current Behavior

Currently if a Route53 DNS entry is used for writer and reader, we get a connectivity failure

Reproduction Steps

CNAME Route53 records required on top of RDS cluster endpoint (one for writer, one for reader)

Possible Solution

No response

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.1.2

JDK version used

1.8 and 17

Operating System and version

ECS Fargate

DBeaver can not select schema

Describe the bug

Unable to choose an available schema once connected

Expected Behavior

Drop down closes, selecting the correct schema

Current Behavior

Drop down closes, but value in tool bar remains "N/A"

Queries entered need to fully specify the schema.tablename or use "use schema".

Reproduction Steps

Set up new driver as per the README (separate MR opened to correct the URL template ; #260)

Create new connection using new driver

Open the new connection as SQL Console

Pick a schema from the drop down list in toolbar, next to where it lists the connection name

Possible Solution

No response

Additional Information/Context

DBeaver 22.1.5

The AWS JDBC Driver for MySQL version used

1.1.0

JDK version used

openjdk 11.0.12 2021-07-20

Operating System and version

Ubuntu 20.04 LTS

Getting false positive errors after failover

Describe the bug

Hello,
We are using an EJB3 based application that is deployed on JBoss EAP 6.
We lookup on data-sources that connects to AWS Aurora DB cluster of 2 nodes.
In order to make the application robust against DB failover, we are exploring the aws-labs MySQL driver.
When we use this driver and we have a DB failover in the middle of some processing:

  • The driver is able to connect to the new writer instance
  • The DB read and writes are happening correctly (based on some data sampling done)

But our error rate goes very high as the driver starts reporting an error "Unable to establish SQL connection to writer node" for all the operations when there is a DB failover and the application is not restarted.
Functionally this error seems to be false positive. But we wished to seek some assistance to figure out the cause and how to address this error too.
Any pointer would be very helpful.
Thanks!

Expected Behavior

There shouldn't be any error in the log if its connected to new write instance.

Current Behavior

  • The driver is able to connect to the new writer instance
  • The DB read and writes are happening correctly (based on some data sampling done)

But our error rate goes very high as the driver starts reporting an error "Unable to establish SQL connection to writer node" for all the operations when there is a DB failover and the application is not restarted.
Functionally this error seems to be false positive. But we wished to seek some assistance to figure out the cause and how to address this error too.

Reproduction Steps

We have EJB based application which is deployed on Jboss EAP. All the connection details added in standalone.xml.
We are using write node cluster url for connecting to database with aws driver.

<subsystem xmlns="urn:jboss:domain:datasources:1.1"> <datasources> <datasource jta="false" jndi-name="java:/jdbc/datasources/global" pool-name="GlobalDS" enabled="true" use-ccm="false"> <connection-url>jdbc:mysql:aws://dev-xcloud-aurora-cluster.cluster-ceq12wejj76d.us-east-1.rds.amazonaws.com:3306?useSSL=false</connection-url> <driver-class>software.aws.rds.jdbc.mysql.Driver</driver-class> <driver>mysql</driver> <pool> <min-pool-size>25</min-pool-size> <max-pool-size>50</max-pool-size> <flush-strategy>IdleConnections</flush-strategy> </pool> <security> <user-name></user-name> <password></password> </security> <validation> <check-valid-connection-sql>SELECT 1</check-valid-connection-sql> <background-validation>true</background-validation> </validation> <statement> <share-prepared-statements>false</share-prepared-statements> </statement> </datasource> <drivers> <driver name="mysql" module="com.mysql"> <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> </driver> <driver name="h2" module="com.h2database.h2"> <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class> </driver> </drivers> </datasources> </subsystem>

Possible Solution

No response

Additional Information/Context

No response

The AWS JDBC Driver for MySQL version used

1.0

JDK version used

1.8

Operating System and version

EC2 instance of AWS

aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (77,210 > 65,535)

Describe the issue
The max_allowed_packet on the mysql server is configured at 200000. On our client side, we have not set the max_allowed_packet size.

So queries that return a result that is smaller than 200000, don't give problems in general. However on rare occasions we do get the following error:

org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [SELECT notes FROM person WHERE id = ?; Packet for query is too large (77,210 > 65,535). You can change this value on the server by setting the 'max_allowed_packet' variable.; nested exception is software.aws.rds.jdbc.mysql.shading.com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (77,210 > 65,535).

If we restart the application, the query causing the issue, works again.

Driver Version?
software.aws.rds:aws-mysql-jdbc:1.0.0

Java Version?
18

MySQL Version?
8

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.