Ejemplo n.º 1
0
 /**
  * Method declaration
  *
  *
  * @throws Exception
  */
 public void checkpoint()
 {
     close(false);
     sModified = "yes";
     saveProperties();
     cCache.open(false);
     openScript();
 }
Ejemplo n.º 2
0
        /**
         * Method declaration
         *
         *
         * @return
         *
         * @throws Exception
         */
        public bool open()
        {
            bool newdata = false;

            if (Trace.TRACE)
            {
                Trace.trace();
            }

            if (!(new File(sFileProperties)).Exists)
            {
                create();
                // this is a new database
                newdata = true;
            }

            // todo: some parts are not necessary for read-only access
            loadProperties();


            if (bReadOnly == true)
            {
                dDatabase.setReadOnly();

                cCache = new Cache(sFileCache);

                cCache.open(true);
                runScript();

                return(false);
            }

            bool needbackup = false;

            if (sModified.Equals("yes-new-files"))
            {
                renameNewToCurrent(sFileScript);
                renameNewToCurrent(sFileBackup);
            }
            else if (sModified.Equals("yes"))
            {
                if (isAlreadyOpen())
                {
                    throw Trace.error(Trace.DATABASE_ALREADY_IN_USE);
                }

                // recovering after a crash (or forgot to close correctly)
                restoreBackup();

                needbackup = true;
            }

            sModified = "yes";
            saveProperties();

            cCache = new Cache(sFileCache);

            cCache.open(false);
            runScript();

            if (needbackup)
            {
                close(false);
                sModified = "yes";
                saveProperties();
                cCache.open(false);
            }

            openScript();

            // this is a existing database
            return(newdata);
        }
Ejemplo n.º 3
0
        /**
         * Method declaration
         *
         *
         * @return
         *
         * @throws Exception
         */
        public bool open()
        {
            bool newdata = false;

            if (Trace.TRACE)
            {
                Trace.trace();
            }

            if (!(new File(sFileProperties)).Exists)
            {
                create();
                // this is a new database
                newdata = true;
            }

            // todo: some parts are not necessary for read-only access
            loadProperties();

            if (bReadOnly == true)
            {
                dDatabase.setReadOnly();

                cCache = new Cache(sFileCache);

                cCache.open(true);
                runScript();

                return false;
            }

            bool needbackup = false;

            if (sModified.Equals("yes-new-files"))
            {
                renameNewToCurrent(sFileScript);
                renameNewToCurrent(sFileBackup);
            }
            else if (sModified.Equals("yes"))
            {
                if (isAlreadyOpen())
                {
                    throw Trace.error(Trace.DATABASE_ALREADY_IN_USE);
                }

                // recovering after a crash (or forgot to close correctly)
                restoreBackup();

                needbackup = true;
            }

            sModified = "yes";
            saveProperties();

            cCache = new Cache(sFileCache);

            cCache.open(false);
            runScript();

            if (needbackup)
            {
                close(false);
             			    sModified = "yes";
                saveProperties();
                cCache.open(false);
            }

            openScript();

            // this is a existing database
            return newdata;
        }