if (params == null)
{
throw new ConfigurationException("Initializations parameters expected");
}
PropertiesParam prop = params.getPropertiesParam(CONNECTION_PROPERTIES);
if (prop != null)
{
if (prop.getProperty(DRIVER_NAME) == null)
{
throw new ConfigurationException("driverClassName expected in db-connection properties section");
}
serverUrl = prop.getProperty(SERVER_URL);
if (serverUrl == null)
{
throw new ConfigurationException("url expected in db-connection properties section");
}
if (prop.getProperty(USERNAME) == null)
{
throw new ConfigurationException("username expected in db-connection properties section");
}
if (prop.getProperty(PASSWORD) == null)
{
throw new ConfigurationException("password expected in db-connection properties section");
}
// Store all connection properties into single map
Iterator<Property> pit = prop.getPropertyIterator();
connectionProperties = new HashMap<String, String>();
while (pit.hasNext())
{
Property p = pit.next();
if (!p.getName().equalsIgnoreCase(SERVER_URL))
{
connectionProperties.put(p.getName(), p.getValue());
}
}
}
else
{
throw new ConfigurationException("db-connection properties expected in initializations parameters");
}
prop = params.getPropertiesParam(DB_CREATION_PROPERTIES);
if (prop != null)
{
String scriptPath = prop.getProperty(DB_SCRIPT_PATH);
if (scriptPath != null)
{
this.dbScript = findScriptResource(scriptPath, cm);
}
else
{
throw new ConfigurationException("scriptPath expected in db-creation properties section");
}
this.dbUserName = prop.getProperty(DB_USERNAME);
if (dbUserName == null)
{
throw new ConfigurationException("username expected in db-creation properties section");
}
this.dbPassword = prop.getProperty(DB_PASSWORD);
if (dbPassword == null)
{
throw new ConfigurationException("password expected in db-creation properties section");
}
}