Checks to see if the exception indicates that the current connection is read-only. @param ex @return
(SQLException ex)
| 650 | * @return |
| 651 | */ |
| 652 | private boolean indicatesReadOnly(SQLException ex) { |
| 653 | String sqlState = ex.getSQLState(); |
| 654 | int errorCode = ex.getErrorCode(); |
| 655 | |
| 656 | LOG.debug("sql state [{}] and error code [{}]", sqlState, errorCode); |
| 657 | |
| 658 | if (sqlState == null) { |
| 659 | return false; |
| 660 | } |
| 661 | |
| 662 | // ------------------ |
| 663 | // SqlServer: "SELECT TOP 10 * FROM sys.messages" |
| 664 | // ------------------ |
| 665 | if (errorCode == 3906 && sqlState.equals("S0002")) { |
| 666 | return true; |
| 667 | } |
| 668 | |
| 669 | // ------------------ |
| 670 | // MYSQL: |
| 671 | // https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-error-sqlstates.html |
| 672 | // ------------------ |
| 673 | // TODO |
| 674 | |
| 675 | // ------------------ |
| 676 | // POSTGRES: https://www.postgresql.org/docs/current/errcodes-appendix.html |
| 677 | // ------------------ |
| 678 | // TODO |
| 679 | |
| 680 | return false; |
| 681 | } |
| 682 | |
| 683 | private boolean isRetryable(SQLException ex) { |
| 684 |