/*
  * Reset the underlying JDBC database tables
  */
 private Pair<Long, URI> resetDatabaseTables(
     NodeCentricOperationContext connectionContext, boolean hardReset) throws AnzoException {
   try {
     dropTables(connectionContext, hardReset);
     datasource.begin(connectionContext.getConnection(), true, true);
     Long ts = Long.valueOf(0);
     LastTransactionTime.insertFirstTransactionTime(
         connectionContext.getStatementProvider(), connectionContext.getConnection(), ts);
     URI serverUri = UriGenerator.generateServerIdURI();
     Long serverId =
         connectionContext.getNodeLayout().store(serverUri, connectionContext.getConnection(), 1);
     ServerRdbWrapper.setServerId(
         connectionContext.getStatementProvider(), connectionContext.getConnection(), serverId);
     connectionContext
         .getNodeLayout()
         .store(Constants.EVERYONE_ROLE, connectionContext.getConnection(), 1);
     datasource.commit(connectionContext.getConnection(), true, true);
     connectionContext.getNodeLayout().commitReferencedIds(connectionContext.getConnection(), 1);
     return new Pair<Long, URI>(serverId, serverUri);
   } catch (Exception e) {
     log.error(LogUtils.RDB_MARKER, "SQL Error resetting database tables", e);
     datasource.abort(connectionContext.getConnection(), true, true);
     throw new AnzoException(ExceptionConstants.RDB.OPERATION_ERROR, e, e.getMessage());
   }
 }
 private void unLockDB(
     NodeCentricOperationContext connectionContext, boolean passed, long serverId) {
   if (passed) {
     try {
       ServerRdbWrapper.setInitialized(
           connectionContext.getStatementProvider(), connectionContext.getConnection(), serverId);
     } catch (AnzoException sqle) {
       log.error(LogUtils.RDB_MARKER, "Error unlocking db", sqle);
     }
   } else {
     try {
       ServerRdbWrapper.setInitializingFailed(
           connectionContext.getStatementProvider(), connectionContext.getConnection());
     } catch (AnzoException sqle) {
       log.error(LogUtils.RDB_MARKER, "Error unlocking db", sqle);
     }
   }
 }
 private boolean[] lockDB(NodeCentricOperationContext connectionContext) {
   boolean ownsIt = false;
   try {
     connectionContext
         .getStatementProvider()
         .runSQLGroup(
             initServerStatement, datasource.getInitParams(), connectionContext.getConnection());
     ownsIt = true;
   } catch (SQLException sqle) {
     if (log.isDebugEnabled()) {
       log.debug(LogUtils.RDB_MARKER, "SQL Error initializing SERVER table", sqle);
     }
   } catch (RdbException sqle) {
     if (log.isDebugEnabled()) {
       log.debug(LogUtils.RDB_MARKER, "SQL Error initializing SERVER table", sqle);
     }
   }
   try {
     int counter =
         ServerRdbWrapper.setInitializing(
             connectionContext.getStatementProvider(),
             connectionContext.getConnection(),
             System.currentTimeMillis());
     if (counter == 0) {
       ServerRdbWrapper.setInitializingFailed(
           connectionContext.getStatementProvider(), connectionContext.getConnection());
       return new boolean[] {ownsIt, false};
     }
     return new boolean[] {ownsIt, true};
   } catch (AnzoException sqle) {
     if (log.isErrorEnabled()) {
       log.error(LogUtils.RDB_MARKER, "Error unlocking db", sqle);
     }
     return new boolean[] {ownsIt, false};
   }
 }