XMLStreamException, ClassNotFoundException, RegistryException {
try {
if (log.isDebugEnabled()) {
log.debug("Dropping Database" + dbName);
}
DatabaseInstanceInfo instanceInfo = tenantData.getDatabaseInstanceInfo(instanceName);
DatabaseUserInfo userInfo = tenantData.getDatabaseUserInfo(instanceName, dbName);
String dropDatabaseQuery = "DROP DATABASE " + dbName;
String dropUserQuery = "DROP USER '" + userInfo.getUsername() + "'@'" +
this.extractHostName(instanceInfo.getInstanceUrl()) + "'";
ps = ConnectionHandler.getConnection(
instanceInfo.getInstanceUrl(),
instanceInfo.getUsername(),
instanceInfo.getPassword()).prepareStatement(dropDatabaseQuery);
ps.execute();
if (log.isDebugEnabled()) {
log.debug("Database " + dbName + "Dropped");
}
if (log.isDebugEnabled()) {
log.debug("Dropping Database User " + userInfo.getUsername());
}
ps = ConnectionHandler.getConnection(
instanceInfo.getInstanceUrl(),
instanceInfo.getUsername(),
instanceInfo.getPassword()).prepareStatement(dropUserQuery);
ps.execute();
if (log.isDebugEnabled()) {
log.debug("Database User " + userInfo.getUsername() + "Dropped");
}