I'm working with GridDB CE in a Java application and trying to programmatically delete a database. However, I'm encountering that error.
> 145045 JC_DATABASE_NOT_EMPTY ERROR Checking of client request failed. Number of DB containers may not be zero. Delete all containers in the DB targeted for deletion.
I want to delete an entire database (or simulate that by removing all its data). For example, before running an integration test or during cleanup, I want to ensure the DB is clean.
import com.toshiba.mwcloud.gs.*;
public class GridDBCleanup {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.setProperty("notificationAddress", "239.0.0.1");
props.setProperty("notificationPort", "31999");
props.setProperty("clusterName", "myCluster");
props.setProperty("user", "admin");
props.setProperty("password", "admin");
GridStore store = GridStoreFactory.getInstance().getGridStore(props);
// Attempt to drop database (simulated cleanup)
store.dropDatabase("testDB"); // This line throws the error
}
}
I've Tried
Ensured that testDB exists and is accessible.
Verified that containers are still present using getContainerNames.
Tried iterating and deleting containers manually before calling dropDatabase, but I want to know if there's a better/more idiomatic way to clean a DB.
What is the correct approach to fully delete a database or simulate that in GridDB?
Do I have to delete all containers manually before using dropDatabase()?
Is there a built-in way to list and delete all containers programmatically?
Any help or a working snippet would be appreciated!
Asked by omar esawy
(11 rep)
Jun 8, 2025, 09:06 AM
Last activity: Jun 8, 2025, 01:03 PM
Last activity: Jun 8, 2025, 01:03 PM