Drop a database removes all the collections and indexes associated plus all data files. It simply cleans up the complete database.
This command obtains a global write lock and will block other operations until it has completed.
To drop a single database :
1) Load the DB object for the database
2) Call the dropDatabase() method
To drop all the database in MongoDB in java :
1) Iterate through the list of database names
2) Load the DB object for the database
3) Call the dropDatabase() method
Java Program :