{
//dbHome must exist and have write permission
final File fDBHome = new File(dbHome);
String dbLogFileName = "";
final StringManager lsm = StringManager.getManager(DerbyControl.class);
if (fDBHome.isDirectory() && fDBHome.canWrite()) {
final File fDBLog = new File(dbHome, DB_LOG_FILENAME);
dbLogFileName = fDBLog.toString();
//if the file exists, check if it is writeable
if (fDBLog.exists() && !fDBLog.canWrite()) {
System.out.println(lsm.getString("UnableToAccessDatabaseLog", dbLogFileName));
System.out.println(lsm.getString("ContinueStartingDatabase"));
//if exist but not able to write then create a temporary
//log file and persist on starting the database
dbLogFileName = createTempLogFile();
}
else if (!fDBLog.exists()) {
//create log file
if (!fDBLog.createNewFile()) {
System.out.println(lsm.getString("UnableToCreateDatabaseLog", dbLogFileName));
}
}
}
else {
System.out.println(lsm.getString("InvalidDBDirectory", dbHome));
System.out.println(lsm.getString("ContinueStartingDatabase"));
//if directory does not exist then create a temporary log file
//and persist on starting the database
dbLogFileName = createTempLogFile();
}
return dbLogFileName;