I don't know if this is the best way. To test if a database exists, I simply send a GET request to https://<host>:<port>/<context>/rest/<database> and check the response status code. A 200 OK response indicates that the database exists and a 404 Not Found response means that the database doesn't exists. Similarly, I send a GET request to https://<host>:<port>/<context>/rest/<database>/<file> and test the response status to test if a file exists.

Geoff Alexander, Ph.D.
Software Engineer, Corporate Tools Development
IBM Corporation
Charlotte, NC