A database is an integral part of many Java applications, both Core Java, and Web application, and probably the biggest obstacle while doing unit testing.
It's not reliable to connect to Dev or UAT database for integration tests because anyone can change the data and schema like tables, stored procedures and it will cause your automated integration test to fail.
DbUnit is a JUnit extension that can be used to initialize the database into a known state before each integration test and ensure that the database contains the correct data.
DbUnit has its own issues, but it is a very useful tool because it helps us to separate the test data creation from the tested code.