When using the Lotus Domino Java API Database.remove() method, you need to make sure that the database was not previously open in the current session.
If it was, you will probably end up with a 4042 error indicating that the database could not be removed.
The best way to do the remove is create a database object and just hang on to it. When you are ready to remove the database, invoke the remove() method on the original database object instead of trying to create a new one.
Although the Database class has open() and isOpen() methods, it does not have a close() method.