activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtaylor <...@git.apache.org>
Subject [GitHub] activemq-artemis pull request #961: ARTEMIS-920 Log SQL Exceptions and Warni...
Date Mon, 16 Jan 2017 15:31:36 GMT
Github user mtaylor commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/961#discussion_r96252766
  
    --- Diff: artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/drivers/AbstractJDBCDriver.java
---
    @@ -61,74 +64,121 @@ public AbstractJDBCDriver(DataSource dataSource, SQLProvider provider)
{
           this.sqlProvider = provider;
        }
     
    -   public void start() throws Exception {
    +   public void start() throws SQLException {
           connect();
           createSchema();
           prepareStatements();
        }
     
        public void stop() throws SQLException {
           if (sqlProvider.closeConnectionOnShutdown()) {
    -         connection.close();
    +         try {
    +            connection.close();
    +         } catch (SQLException e) {
    +            logger.error(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), e));
    +            throw e;
    +         }
           }
        }
     
        protected abstract void prepareStatements() throws SQLException;
     
        protected abstract void createSchema() throws SQLException;
     
    -   protected void createTable(String... schemaSqls) throws SQLException {
    +   protected final void createTable(String... schemaSqls) throws SQLException {
           createTableIfNotExists(connection, sqlProvider.getTableName(), schemaSqls);
        }
     
    -   protected void connect() throws Exception {
    +   private void connect() throws SQLException {
           if (dataSource != null) {
    -         connection = dataSource.getConnection();
    +         try {
    +            connection = dataSource.getConnection();
    +         } catch (SQLException e) {
    +            logger.error(JDBCUtils.appendSQLExceptionDetails(new StringBuilder(), e));
    +            throw e;
    --- End diff --
    
    Usually the database will throw an exception if a table already exists.  This is not an
error (the table will only be created the first time the servers starts).  However, this code
change would log an error each time the server restarts.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message