KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > ext > mssql > MsSqlConnection


1 /*
2  *
3  * The DbUnit Database Testing Framework
4  * Copyright (C)2002-2004, DbUnit.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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.dbunit.database.DatabaseConfig;
24 import org.dbunit.database.DatabaseConnection;
25 import org.dbunit.dataset.FilteredDataSet;
26 import org.dbunit.dataset.IDataSet;
27 import org.dbunit.dataset.filter.ExcludeTableFilter;
28 import org.dbunit.dataset.filter.ITableFilter;
29
30 import java.sql.Connection JavaDoc;
31 import java.sql.SQLException JavaDoc;
32
33 /**
34  * @author Manuel Laflamme
35  * @since May 19, 2003
36  * @version $Revision: 1.2 $
37  */

38 public class MsSqlConnection extends DatabaseConnection
39 {
40     private final ITableFilter _filter = new ExcludeTableFilter(
41             new String JavaDoc[] {"dtproperties"});
42
43     /**
44      * Creates a new <code>MsSqlConnection</code>.
45      *
46      * @param connection the adapted JDBC connection
47      * @param schema the database schema
48      */

49     public MsSqlConnection(Connection connection, String JavaDoc schema)
50     {
51         super(connection, schema);
52         getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
53                 new MsSqlDataTypeFactory());
54     }
55
56     /**
57      * Creates a new <code>MsSqlConnection</code>.
58      *
59      * @param connection the adapted JDBC connection
60      */

61     public MsSqlConnection(Connection connection)
62     {
63         super(connection);
64         getConfig().setProperty(DatabaseConfig.PROPERTY_DATATYPE_FACTORY,
65                 new MsSqlDataTypeFactory());
66     }
67
68     ////////////////////////////////////////////////////////////////////////////
69
// IDatabaseConnection
70

71     public IDataSet createDataSet() throws SQLException JavaDoc
72     {
73         IDataSet dataSet = super.createDataSet();
74         return new FilteredDataSet(_filter, dataSet);
75     }
76
77     public IDataSet createDataSet(String JavaDoc[] tableNames) throws SQLException JavaDoc
78     {
79         IDataSet dataSet = super.createDataSet(tableNames);
80         return new FilteredDataSet(_filter, dataSet);
81     }
82 }
83
Popular Tags