Hi,
I think of opening a database, in general, as something you wouldn’t want to do every time you do any operation. I would expect:
open the database do stuff do stuff do stuff do stuff do stuff close the database
not
open the database and do stuff open the database and do stuff open the database and do stuff open the database and do stuff close the database
Is using CHECK when the database is already open comparable in CPU cycles to testing a boolean variable that says open true or false? I understand that the time it takes for most commands to execute would make code logic usually insignificant.
Kendall
On 6/18/16, 4:54 AM, "Christian Grün" christian.gruen@gmail.com wrote:
Hi Kendall,
I would indeed recommend you to use the CHECK command before doing any other operations. This command does exactly what you seem to be looking for (checking if the databases is opened; if not, open it).
Does this help? Christian
On Wed, Jun 15, 2016 at 7:03 PM, Kendall Shaw kendall.shaw@workday.com wrote:
Using ClientSession from java, I do this to check if the database is open:
try {
replace(somewhere, new ArrayInput(bytes));
} catch (IOException e) { String msg = e.getMessage();
if (msg == null || !msg.contains(“No database opened”))
throw e;
execute(new Check(databaseName));
replace(somewhere, new ArrayInput(bytes));
}
Is there a better way to detect if the database is open than testing the exception message text?
Kendall