Search in sources :

Example 1 with ITableMetaData

use of org.dbunit.dataset.ITableMetaData in project nextprot-api by calipho-sib.

the class FlatXmlDataSetExtractor method toString.

public String toString() {
    StringBuilder sb = new StringBuilder();
    try {
        for (String tableName : ds.getTableNames()) {
            sb.append("Table:").append(tableName).append("\n");
            ITable table = ds.getTable(tableName);
            for (int i = 0; i < table.getRowCount(); i++) {
                ITableMetaData md = table.getTableMetaData();
                sb.append("    ");
                for (Column col : md.getColumns()) {
                    sb.append(col.getColumnName()).append(": ").append(table.getValue(i, col.getColumnName()));
                    sb.append(", ");
                }
                sb.delete(sb.length() - 2, sb.length());
                sb.append("\n");
            }
        }
    } catch (DataSetException e) {
        sb.append("Error: ").append(e.getMessage());
    }
    return sb.toString();
}
Also used : DataSetException(org.dbunit.dataset.DataSetException) Column(org.dbunit.dataset.Column) ITableMetaData(org.dbunit.dataset.ITableMetaData) ITable(org.dbunit.dataset.ITable)

Example 2 with ITableMetaData

use of org.dbunit.dataset.ITableMetaData in project sharding-jdbc by shardingjdbc.

the class SQLAssertHelper method createTable.

private CachedResultSetTable createTable(final String tableName, final PreparedStatement preparedStatement, final IDatabaseConnection connection) throws SQLException, DataSetException {
    preparedStatement.execute();
    ResultSet rs = preparedStatement.getResultSet();
    ITableMetaData metaData = new ResultSetTableMetaData(tableName, rs, connection, false);
    ForwardOnlyResultSetTable table = new ForwardOnlyResultSetTable(metaData, rs);
    return new CachedResultSetTable(table);
}
Also used : ForwardOnlyResultSetTable(org.dbunit.database.ForwardOnlyResultSetTable) ResultSetTableMetaData(org.dbunit.database.ResultSetTableMetaData) CachedResultSetTable(org.dbunit.database.CachedResultSetTable) ResultSet(java.sql.ResultSet) ITableMetaData(org.dbunit.dataset.ITableMetaData)

Aggregations

ITableMetaData (org.dbunit.dataset.ITableMetaData)2 ResultSet (java.sql.ResultSet)1 CachedResultSetTable (org.dbunit.database.CachedResultSetTable)1 ForwardOnlyResultSetTable (org.dbunit.database.ForwardOnlyResultSetTable)1 ResultSetTableMetaData (org.dbunit.database.ResultSetTableMetaData)1 Column (org.dbunit.dataset.Column)1 DataSetException (org.dbunit.dataset.DataSetException)1 ITable (org.dbunit.dataset.ITable)1