public void deleteData(DataSource dataSource) throws Exception
{
if (dataSource instanceof RelationalDatabase)
{
RelationalDatabase database = (RelationalDatabase)dataSource;
SQLAdapter adapter = (SQLAdapter)database.getComponent().getInstance(m_context);
SQLSchemaManager manager = adapter.createSchemaManager(database);
RelationalSchema schema = (RelationalSchema)database.getSchema();
String sOrigFragment = m_context.getFragmentName();
Connection connection = null;
try
{
for (Iterator itr = dataSource.getFragmentIterator(); itr.hasNext();) // each fragment
{
m_context.setFragmentName(((Named)itr.next()).getName()); // connection for fragment
try
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("Deleting data in data source \"" + dataSource.getName() + '"');
}
connection = adapter.getConnectionFactory().getConnection(adapter);
manager.setSQLAppender(new SQLSchemaManager.SQLConnectionAppender(connection, true));
manager.truncateSchema(schema);
if (s_logger.isDebugEnabled())
{
s_logger.debug("Deletion completed");
}
}
finally
{
adapter.close(connection);
}
}
}
finally
{