*/
public DBCreator(InitParams params) throws ConfigurationException
{
if (params == null)
{
throw new ConfigurationException("Initializations parameters expected");
}
PropertiesParam prop = params.getPropertiesParam("db-connection");
if (prop != null)
{
this.driver = prop.getProperty("driverClassName");
if (driver == null)
{
throw new ConfigurationException("driverClassName expected in db-connection properties section");
}
this.serverUrl = prop.getProperty("url");
if (serverUrl == null)
{
throw new ConfigurationException("url expected in db-connection properties section");
}
this.adminName = prop.getProperty("username");
if (adminName == null)
{
throw new ConfigurationException("username expected in db-connection properties section");
}
this.adminPwd = prop.getProperty("password");
if (adminPwd == null)
{
throw new ConfigurationException("password expected in db-connection properties section");
}
this.internal_logon = prop.getProperty("internal_logon");
}
else
{
throw new ConfigurationException("db-connection properties expected in initializations parameters");
}
prop = params.getPropertiesParam("db-creation");
if (prop != null)
{
String scriptPath = prop.getProperty("scriptPath");
if (scriptPath != null)
{
try
{
dbScript = readScriptResource(scriptPath);
}
catch (IOException e)
{
throw new ConfigurationException("Can't read script resource " + scriptPath, e);
}
}
else
{
throw new ConfigurationException("scriptPath expected in db-creation properties section");
}
this.dbUserName = prop.getProperty("username");
if (dbUserName == null)
{
throw new ConfigurationException("username expected in db-creation properties section");
}
this.dbPassword = prop.getProperty("password");
if (dbPassword == null)
{
throw new ConfigurationException("password expected in db-creation properties section");
}
}
else
{
throw new ConfigurationException("db-creation properties expected in initializations parameters");
}
}