public synchronized void close() throws SQLException {
    if (this.pooledConnection == null) {
      // no-op
      return;
    }

    MysqlPooledConnection con = this.pooledConnection; // we need this later...

    try {
      super.close();
    } finally {
      try {
        StatementEvent e = new StatementEvent(con, this);
        // todo: pull this all up into base classes when we support *only* JDK6 or newer
        if (con instanceof JDBC4MysqlPooledConnection) {
          ((JDBC4MysqlPooledConnection) con).fireStatementEvent(e);
        } else if (con instanceof JDBC4MysqlXAConnection) {
          ((JDBC4MysqlXAConnection) con).fireStatementEvent(e);
        } else if (con instanceof JDBC4SuspendableXAConnection) {
          ((JDBC4SuspendableXAConnection) con).fireStatementEvent(e);
        }
      } finally {
        this.unwrappedInterfaces = null;
      }
    }
  }
Example #2
0
 ResultSetWrapper getTimestampResultSetWrapperWithNulls(Connection connection)
     throws SQLException {
   DatabaseMetaData metaData = connection.getMetaData();
   connection
       .createStatement()
       .execute(
           "create table test1 (id int primary key, test1 timestamp, test2 date, test3 time)");
   PreparedStatement statement =
       connection.prepareStatement("insert into test1 values (?, ?, ?, ?)");
   statement.setInt(1, 1);
   PreparedStatementWrapper statementWrapper = new PreparedStatementWrapper(statement);
   statementWrapper.setLocalDateTime(2, null);
   statementWrapper.setLocalDate(3, null);
   statementWrapper.setLocalTime(4, null);
   assertEquals(1, statement.executeUpdate());
   ResultSet resultSet = connection.createStatement().executeQuery("select * from test1");
   assertTrue(resultSet.next());
   return new ResultSetWrapper(metaData, resultSet);
 }