KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > database > DatabaseConnection


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
22 package org.dbunit.database;
23
24 import java.sql.Connection JavaDoc;
25 import java.sql.SQLException JavaDoc;
26
27 /**
28  * This class adapts a JDBC <code>Connection</code> to a
29  * {@link IDatabaseConnection}.
30  *
31  * @author Manuel Laflamme
32  * @version $Revision: 1.11 $
33  * @since Feb 21, 2002
34  */

35 public class DatabaseConnection extends AbstractDatabaseConnection
36         implements IDatabaseConnection
37 {
38     private final Connection JavaDoc _connection;
39     private final String JavaDoc _schema;
40
41     /**
42      * Creates a new <code>DatabaseConnection</code>.
43      *
44      * @param connection the adapted JDBC connection
45      * @param schema the database schema
46      */

47     public DatabaseConnection(Connection JavaDoc connection, String JavaDoc schema)
48     {
49         _connection = connection;
50         _schema = schema;
51     }
52
53     /**
54      * Creates a new <code>DatabaseConnection</code>.
55      *
56      * @param connection the adapted JDBC connection
57      */

58     public DatabaseConnection(Connection JavaDoc connection)
59     {
60         _connection = connection;
61         _schema = null;
62     }
63
64     ////////////////////////////////////////////////////////////////////////////
65
// IDatabaseConnection interface
66

67     public Connection JavaDoc getConnection() throws SQLException JavaDoc
68     {
69         return _connection;
70     }
71
72     public String JavaDoc getSchema()
73     {
74         return _schema;
75     }
76
77     public void close() throws SQLException JavaDoc
78     {
79         _connection.close();
80     }
81 }
82
83
84
85
86
87
88
Popular Tags