001: /*
002: *
003: * The DbUnit Database Testing Framework
004: * Copyright (C)2002-2004, DbUnit.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: */
021:
022: package org.dbunit.database;
023:
024: import org.dbunit.database.statement.IStatementFactory;
025: import org.dbunit.dataset.DataSetException;
026: import org.dbunit.dataset.IDataSet;
027: import org.dbunit.dataset.ITable;
028:
029: import java.sql.Connection;
030: import java.sql.SQLException;
031:
032: /**
033: * This interface represents a connection to a specific database.
034: *
035: * @author Manuel Laflamme
036: * @version $Revision: 399 $
037: * @since Mar 6, 2002
038: */
039: public interface IDatabaseConnection {
040: /**
041: * Returns a JDBC database connection.
042: */
043: public Connection getConnection() throws SQLException;
044:
045: /**
046: * Returns the database schema name.
047: */
048: public String getSchema();
049:
050: /**
051: * Close this connection.
052: */
053: public void close() throws SQLException;
054:
055: /**
056: * Creates a dataset corresponding to the entire database.
057: */
058: public IDataSet createDataSet() throws SQLException;
059:
060: /**
061: * Creates a dataset containing only the specified tables from
062: * the database.
063: */
064: public IDataSet createDataSet(String[] tableNames)
065: throws SQLException;
066:
067: /**
068: * Creates a table with the result of the specified SQL statement. The
069: * table can be the result of a join statement.
070: *
071: * @param resultName The name to be returned by {@link org.dbunit.dataset.ITableMetaData#getTableName}.
072: * @param sql The SQL <code>SELECT</code> statement
073: */
074: public ITable createQueryTable(String resultName, String sql)
075: throws DataSetException, SQLException;
076:
077: /**
078: * Returns the specified table row count.
079: *
080: * @param tableName the table name
081: * @return the row count
082: */
083: public int getRowCount(String tableName) throws SQLException;
084:
085: /**
086: * Returns the specified table row count according specified where clause.
087: *
088: * @param tableName the table name
089: * @param whereClause the where clause
090: * @return the row count
091: */
092: public int getRowCount(String tableName, String whereClause)
093: throws SQLException;
094:
095: /**
096: * Returns this connection database configuration
097: */
098: public DatabaseConfig getConfig();
099:
100: /**
101: * @deprecated Use {@link #getConfig}
102: */
103: public IStatementFactory getStatementFactory();
104: }
|