01: /*
02: *
03: * The DbUnit Database Testing Framework
04: * Copyright (C)2002-2004, DbUnit.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: *
20: */
21: package org.dbunit.ext.mssql;
22:
23: import org.slf4j.Logger;
24: import org.slf4j.LoggerFactory;
25:
26: import org.dbunit.database.DatabaseConfig;
27: import org.dbunit.database.DatabaseConnection;
28: import org.dbunit.dataset.FilteredDataSet;
29: import org.dbunit.dataset.IDataSet;
30: import org.dbunit.dataset.filter.ExcludeTableFilter;
31: import org.dbunit.dataset.filter.ITableFilter;
32:
33: import java.sql.Connection;
34: import java.sql.SQLException;
35:
36: /**
37: * @author Manuel Laflamme
38: * @since May 19, 2003
39: * @version $Revision: 554 $
40: */
41: public class MsSqlConnection extends DatabaseConnection {
42:
43: /**
44: * Logger for this class
45: */
46: private static final Logger logger = LoggerFactory
47: .getLogger(MsSqlConnection.class);
48:
49: private final ITableFilter _filter = new ExcludeTableFilter(
50: new String[] { "dtproperties" });
51:
52: /**
53: * Creates a new <code>MsSqlConnection</code>.
54: *
55: * @param connection the adapted JDBC connection
56: * @param schema the database schema
57: */
58: public MsSqlConnection(Connection connection, String schema) {
59: super (connection, schema);
60: getConfig().setProperty(
61: DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
62: new MsSqlDataTypeFactory());
63: }
64:
65: /**
66: * Creates a new <code>MsSqlConnection</code>.
67: *
68: * @param connection the adapted JDBC connection
69: */
70: public MsSqlConnection(Connection connection) {
71: super (connection);
72: getConfig().setProperty(
73: DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
74: new MsSqlDataTypeFactory());
75: }
76:
77: ////////////////////////////////////////////////////////////////////////////
78: // IDatabaseConnection
79:
80: public IDataSet createDataSet() throws SQLException {
81: logger.debug("createDataSet() - start");
82:
83: IDataSet dataSet = super .createDataSet();
84: return new FilteredDataSet(_filter, dataSet);
85: }
86:
87: public IDataSet createDataSet(String[] tableNames)
88: throws SQLException {
89: logger.debug("createDataSet(tableNames=" + tableNames
90: + ") - start");
91:
92: IDataSet dataSet = super .createDataSet(tableNames);
93: return new FilteredDataSet(_filter, dataSet);
94: }
95: }
|