code: public static Connection wrapConnection(Connection connection) {
          try {
              if(connection.isWrapperFor(ConnectionWrapper.class)) {
                  return connection;
              } else {
                  return new ConnectionWrapper(connection);
              }
          } catch (SQLException ex) {
              return new ConnectionWrapper(connection);
          }
      }
docs: Use this only if DataSource is not available.
  In order to be able to use {@link ResultSet#unwrap(Class)} and
  {@link java.sql.ResultSetMetaData#unwrap(Class)} to get {@link SpatialResultSet} and
  {@link SpatialResultSetMetaData} this method wrap the provided connection.
  
  @param connection H2 or PostGIS Connection
  
  @return Wrapped DataSource, with spatial methods