/**
 * Copyright 2007 Matthew Hillsdon
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.hillsdon.svnwiki.wiki.db.model;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import net.hillsdon.fij.collections.DelegatingTransformMap;
import net.hillsdon.fij.collections.TransformMap;

public class DBSchema extends DBCreatableObject {

  private TransformMap<String, DBTable> _tables = new DelegatingTransformMap<String, DBTable>(DBNamedObject.TO_NAME);
  
  public DBSchema(String name) {
    super(name);
  }

  public TransformMap<String, DBTable> tables() {
    return _tables;
  }
  
  @Override
  public boolean exists(Connection connection) throws SQLException {
    ResultSet schemas = connection.getMetaData().getSchemas(null, getName());
    try {
      return schemas.next();
    }
    finally {
      schemas.close();
    }
  }

  public String toSql() {
    return "create schema " + getName();
  }


}

@@ -1026,16 +1026,22 @@
 BSchema(
+final 
 String n
@@ -1182,16 +1182,22 @@
  exists(
+final 
 Connecti
@@ -1297,14 +1297,114 @@
 mas(
-null, 
+);%0A    try %7B%0A      while (schemas.next()) %7B%0A        if (schemas.getString(%22TABLE_SCHEM%22).equalsIgnoreCase(
 getN
@@ -1413,47 +1413,71 @@
 e())
-;
+) %7B
 %0A    
-try %7B%0A      return schemas.next()
+      return true;%0A        %7D%0A      %7D%0A      return false
 ;%0A  

Rewrite to avoid 1.6 specific method.