X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2Fpersistence%2FDatabaseUtils.java;h=5f26bd8e0dceab7d128684399eacb51727d950bc;hb=5e33a52ba36ac928b9863ddd79d2d09f6a308af6;hp=bc62274914081d199aa9cd427cd0943bca2b5433;hpb=ddf9dde0d0afce66159d78705eddcb530849ed32;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java index bc622749..5f26bd8e 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseUtils.java @@ -12,7 +12,7 @@ * 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 org.wamblee.support.persistence; import java.sql.Connection; @@ -146,15 +146,20 @@ public class DatabaseUtils { LOG.fine("Getting database table names to clean (schema: '" + SCHEMA_PATTERN + "'"); - ResultSet tables = dataSource.getConnection().getMetaData().getTables( - null, SCHEMA_PATTERN, "%", new String[] { "TABLE" }); - while (tables.next()) { - String table = tables.getString("TABLE_NAME"); - if (aSelection.accept(table)) { - result.add(table); + Connection connection = dataSource.getConnection(); + try { + ResultSet tables = connection.getMetaData().getTables(null, + SCHEMA_PATTERN, "%", new String[] { "TABLE" }); + while (tables.next()) { + String table = tables.getString("TABLE_NAME"); + if (aSelection.accept(table)) { + result.add(table); + } } + return (String[]) result.toArray(new String[0]); + } finally { + connection.close(); } - return (String[]) result.toArray(new String[0]); } public void emptyTables() throws Exception { @@ -363,7 +368,7 @@ public class DatabaseUtils { if (aObject instanceof Integer) { aStatement.setInt(aIndex, ((Integer) aObject).intValue()); } else if (aObject instanceof Long) { - aStatement.setLong(aIndex, ((Integer) aObject).longValue()); + aStatement.setLong(aIndex, ((Long) aObject).longValue()); } else if (aObject instanceof String) { aStatement.setString(aIndex, (String) aObject); } else {