Package org.dbunit.database
Class ResultSetTableMetaData
java.lang.Object
org.dbunit.dataset.AbstractTableMetaData
org.dbunit.database.ResultSetTableMetaData
- All Implemented Interfaces:
ITableMetaData
ResultSet based ITableMetaData implementation.
The lookup for the information needed to create the Column objects is retrieved
in two phases:
- Try to find the information from the given
ResultSetvia aDatabaseMetaDataobject. Therefore theResultSetMetaDatais used to get the catalog/schema/table/column names which in turn are used to get column information viaDatabaseMetaData.getColumns(String, String, String, String). The reason for this is that theDatabaseMetaDatais more precise and contains more information about columns than theResultSetMetaDatadoes. Another reason is that some JDBC drivers (currently known from MYSQL driver) provide an inconsistent implementation of those two MetaData objects and theDatabaseMetaDatais hence considered to be the master by dbunit. -
Since some JDBC drivers (one of them being Oracle) cannot (or just do not) provide the
catalog/schema/table/column values on a
ResultSetMetaDatainstance the second step will create the dbunitColumnusing theResultSetMetaDatamethods directly (for exampleResultSetMetaData.getColumnType(int). (This is also the way dbunit worked until the 2.4 release)
- Since:
- 2.3.0
- Version:
- $Revision$ $Date$
- Author:
- gommma (gommma AT users.sourceforge.net), Last changed by: $Author$
-
Constructor Summary
ConstructorsConstructorDescriptionResultSetTableMetaData(String tableName, ResultSet resultSet, IDatabaseConnection connection, boolean caseSensitiveMetaData) ResultSetTableMetaData(String tableName, ResultSet resultSet, IDataTypeFactory dataTypeFactory, boolean caseSensitiveMetaData) Deprecated. -
Method Summary
Methods inherited from class org.dbunit.dataset.AbstractTableMetaData
getColumnIndex, getDataTypeFactory, getPrimaryKeys, getPrimaryKeys
-
Constructor Details
-
ResultSetTableMetaData
public ResultSetTableMetaData(String tableName, ResultSet resultSet, IDatabaseConnection connection, boolean caseSensitiveMetaData) throws DataSetException, SQLException - Parameters:
tableName- The name of the database tableresultSet- The JDBC result set that is used to retrieve the columnsconnection- The connection which is needed to retrieve some configuration valuescaseSensitiveMetaData- Whether or not the metadata is case sensitive- Throws:
DataSetExceptionSQLException
-
ResultSetTableMetaData
public ResultSetTableMetaData(String tableName, ResultSet resultSet, IDataTypeFactory dataTypeFactory, boolean caseSensitiveMetaData) throws DataSetException, SQLException Deprecated.- Parameters:
tableName- The name of the database tableresultSet- The JDBC result set that is used to retrieve the columnsdataTypeFactory-caseSensitiveMetaData- Whether or not the metadata is case sensitive- Throws:
DataSetExceptionSQLException
-
-
Method Details
-
getColumns
Description copied from interface:ITableMetaDataReturns this table columns as recognized by dbunit. In cases where columns are resolved using database metadata it can happen that an empty array is returned when a table does not have a single column that is recognized by the configuredIDataTypeFactory. Note that it is not an exceptional case within dbunit when aITableMetaDatadoes not have a column.- Returns:
- The columns for this table
- Throws:
DataSetException
-
getPrimaryKeys
Description copied from interface:ITableMetaDataReturns this table primary key columns.- Returns:
- this table primary key columns.
- Throws:
DataSetException
-
getTableName
Description copied from interface:ITableMetaDataReturns this table name.- Returns:
- this table name
-
toString
-
ResultSetTableMetaData(String, ResultSet, IDatabaseConnection, boolean)