st.close();
} catch (final Exception e) {
throw new BuildException(e.getMessage());
}
final String version = Version.getVersion(versionString);
final String minVersion = new PropertiesManager().getProperty("db.ora.version");
String msg = "Minimum required version: " + minVersion + ", current version " + version;
if (Version.compareVersion(version, minVersion) < 0)
throw new BuildException(msg
+ "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
else {
log4j.info(msg);
log4j.info("Oracle version OK");
}
// check open_cursors
log4j.info("Checking Oracle open cursors...");
long openCursors = 0;
try {
st = connSystem
.prepareStatement("SELECT value FROM v$parameter WHERE name ='open_cursors'");
result = st.executeQuery();
while (result.next()) {
openCursors = new Long(result.getString(1));
}
result.close();
st.close();
} catch (final Exception e) {
throw new BuildException(e.getMessage());
}
final long minOpenCursors = new Long(new PropertiesManager()
.getProperty("db.ora.opencursors"));
msg = "Minimum open cursors required: " + minOpenCursors + ", current open cursors "
+ openCursors;
if (openCursors < minOpenCursors)
throw new BuildException(msg
+ "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
else {
log4j.info(msg);
log4j.info("Open cursors OK");
}
// check processes
log4j.info("Checking Oracle open cursors...");
long processes = 0;
try {
st = connSystem.prepareStatement("SELECT value FROM v$parameter WHERE name ='processes'");
result = st.executeQuery();
while (result.next()) {
processes = new Long(result.getString(1));
}
result.close();
st.close();
} catch (final Exception e) {
throw new BuildException(e.getMessage());
}
final long minProcesses = new Long(new PropertiesManager().getProperty("db.ora.processes"));
msg = "Minimum open processes required: " + minProcesses + ", current processes " + processes;
if (processes < minProcesses)
throw new BuildException(msg
+ "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#Oracle");
else {
log4j.info(msg);
log4j.info("Open cursors OK");
}
try {
st = connSystem
.prepareStatement("select value from nls_database_parameters where parameter='NLS_NCHAR_CHARACTERSET'");
result = st.executeQuery();
result.next();
String nchar_charset = result.getString(1);
if (nchar_charset.equals("AL16UTF16"))
log4j.info("NCHAR charset encoding OK.");
else {
throw new BuildException("NCHAR charset encoding incorrect. Current encoding: "
+ nchar_charset + ". Required encoding: AL16UTF16");
}
result.close();
st.close();
} catch (final Exception e) {
throw new BuildException(e.getMessage());
}
} else { // PostgreSQL
// Check version
log4j.info("Checking PostgreSQL version...");
String version = "";
try {
st = connSystem
.prepareStatement("SELECT setting FROM pg_settings WHERE name = 'server_version'");
result = st.executeQuery();
while (result.next()) {
version = result.getString(1);
}
result.close();
st.close();
} catch (final Exception e) {
throw new BuildException(e.getMessage());
}
String minVersion = new PropertiesManager().getProperty("db.pg.version");
if (System.getProperty("os.name").equalsIgnoreCase("Windows"))
minVersion = new PropertiesManager().getProperty("db.pg.windows.version");
else
minVersion = new PropertiesManager().getProperty("db.pg.version");
final String msg = "Minimum required version: " + minVersion + ", current version " + version;
if (Version.compareVersion(version, minVersion) < 0)
throw new BuildException(msg
+ "\nTip: check http://wiki.openbravo.com/wiki/Development_Stack_Setup#PostgreSQL");