Precondition with code

Hi all,

I am having the issue with updating the database. My current comnpany 's product need to generate the whole database in the first run time by specifying the database name, then the java code will generate the whole database and tables in it based on the changelog. I successfully called the change log from the code to do that. However, since this version, we need to verify whether the database is from the old version or not. If the specified database is from the old version, then it needs to be updated. If it is new (no table), then it will generate the tables. If the specified database is illeagal (already contains some tables which do not belong to the system), then it will give error.

I cannot solve the illegal database problem since there is no code for the Precondition class called by java. The idea is using the changeSetExecuted functionality in the java code to make sure that the last change set is finished. Is there anyone having any example for using Precondition by code?

Update: I am quite confused about the DatabaseChangeLog class. I tried

  1. DatabaseChangeLog changeLog = new DatabaseChangeLog(dbChangeLogPath);
  2. List listChangeSet = changeLog.getChangeSets();

but the listChangeSet is empty.