comparing 2 tables

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

comparing 2 tables

Rachna Jotwani

I want to compare 2 tables and check what new rows were added , which ones were modified between version 1 and version2.

When I run this code I get the foolwing error.

I thought if I use the DiffCollectingFailureHandler , it should not throw the data mismatch error.

Is something like this supported, or should I be exporting the 2 tables to an xml file and compare the 2 xml files.

 

Exception in thread "main" org.dbunit.assertion.DbComparisonFailure[row count (table=TABLE1_VER1)expected:<3430>but was:<3423>]

       at org.dbunit.assertion.DefaultFailureHandler$DefaultFailureFactory.createFailure(DefaultFailureHandler.java:259)

       at org.dbunit.assertion.DefaultFailureHandler.createFailure(DefaultFailureHandler.java:105)

       at org.dbunit.assertion.DbUnitAssert.assertEquals(DbUnitAssert.java:370)

       at org.dbunit.Assertion.assertEquals(Assertion.java:139)

       at SampleTest.main(SampleTest.java:36)

 

public class SampleTest

{

    public static void main(String[] args) throws Exception

    {

        // database connection

        Class driverClass = Class.forName("oracle.jdbc.driver.OracleDriver");

        Connection jdbcConnection = DriverManager.getConnection(

                "jdbc:oracle:thin:@oracleserver:1521:oraclesid", "schema_version1", "schema_version1");

        IDatabaseConnection connection = new DatabaseConnection(jdbcConnection);

 

        String id = DatabaseConfig.FEATURE_QUALIFIED_TABLE_NAMES;

        DatabaseConfig config = connection.getConfig();

        config.setFeature(id, true);

        // partial database export

        QueryDataSet partialDataSet = new QueryDataSet(connection);

        partialDataSet.addTable("TABLE1_VER1", "SELECT * FROM schema_version1.TABLE1");

        partialDataSet.addTable("TABLE1_VER2", "SELECT * FROM schema_version2.TABLE1");       

        

        

        DiffCollectingFailureHandler myHandler = new DiffCollectingFailureHandler();

        Assertion.assertEquals(partialDataSet.getTable("TABLE1_VER1"),

                     partialDataSet.getTable("TABLE1_VER2"),myHandler);

 

        List diffList = myHandler.getDiffList();

        Difference diff = (Difference)diffList.get(0);

 

       

    }

}


------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
dbunit-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/dbunit-user