private void checkVersion(boolean createSchema)
{
try
{
LOGGER.debug("(checkVersion) Creating VersionDAO object");
VersionDAO versionDAO = new VersionDAO(emf.createEntityManager());
LOGGER.debug("(checkVersion) VersionDAO object created");
// If this is a new install and the option to create the database
// schema is set, do so here
if (createSchema)
{
// Insert the version number in the database
LOGGER.debug("(checkVersion) We created schema...Version stored "
+ "on connect");
versionDAO.create(version);
} else
{
LOGGER.debug("(checkVersion) Schema not created.");
}
if (versionDAO.checkDbVersion(version))
{
LOGGER.debug("(checkVersion) Database version matches "
+ "application version.");
} else
{
LOGGER.error("(checkVersion) Database version does not match. "
+ "Exiting program.");
JOptionPane.showMessageDialog(JCourseManagementApp.getApplication()
.getMainFrame(), "ERROR: This version of "
+ "JCourseManagements is not compatible with the RAGE "
+ "database. Exiting program.",
"ERROR", JOptionPane.ERROR_MESSAGE);
exitApplication();
}
LOGGER.debug("(checkVersion) Closing VersionDAO connection");
versionDAO.closeConnection();
} catch (IllegalStateException ex)
{
LOGGER.warn("(checkVersion) Problem connecting to the database "
+ "with the VersionDAO object");
}