Examples of ScriptReaderBase


Examples of org.hsqldb.scriptio.ScriptReaderBase

  }

  private void processScript()
    throws HsqlException
  {
    ScriptReaderBase localScriptReaderBase = null;
    try
    {
      if ((this.database.isFilesInJar()) || (this.fa.isStreamElement(this.scriptFileName)))
      {
        localScriptReaderBase = ScriptReaderBase.newScriptReader(this.database, this.scriptFileName, this.scriptFormat);
        localScriptReaderBase.readAll(this.database.sessionManager.getSysSession(null, true));
        localScriptReaderBase.close();
      }
    }
    catch (Throwable localThrowable)
    {
      if (localScriptReaderBase != null)
      {
        localScriptReaderBase.close();
        if (this.cache != null)
          this.cache.close(false);
        closeAllTextCaches(false);
      }
      this.database.logger.appLog.logContext(localThrowable, null);
View Full Code Here

Examples of org.hsqldb.scriptio.ScriptReaderBase

    IntKeyHashMap localIntKeyHashMap = new IntKeyHashMap();
    Session localSession1 = paramDatabase.getSessionManager().getSysSession();
    Session localSession2 = localSession1;
    int i = 0;
    paramDatabase.setReferentialIntegrity(false);
    ScriptReaderBase localScriptReaderBase = null;
    try
    {
      StopWatch localStopWatch = new StopWatch();
      localScriptReaderBase = ScriptReaderBase.newScriptReader(paramDatabase, paramString, paramInt);
      while (localScriptReaderBase.readLoggedStatement(localSession2))
      {
        int j = localScriptReaderBase.getSessionNumber();
        if (i != j)
        {
          i = j;
          localSession2 = (Session)localIntKeyHashMap.get(i);
          if (localSession2 == null)
          {
            localSession2 = paramDatabase.getSessionManager().newSession(paramDatabase, localSession1.getUser(), false, true);
            localIntKeyHashMap.put(i, localSession2);
          }
        }
        if (localSession2.isClosed())
        {
          localIntKeyHashMap.remove(i);
          continue;
        }
        Result localResult = null;
        Object[] arrayOfObject;
        switch (localScriptReaderBase.getStatementType())
        {
        case 1:
          localResult = localSession2.sqlExecuteDirectNoPreChecks(localScriptReaderBase.getLoggedStatement());
          if ((localResult == null) || (!localResult.isError()))
            break;
          if (localResult.getException() != null)
            throw localResult.getException();
          throw Trace.error(localResult);
        case 4:
          localScriptReaderBase.getCurrentSequence().reset(localScriptReaderBase.getSequenceValue());
          break;
        case 5:
          localSession2.commit();
          break;
        case 3:
          arrayOfObject = localScriptReaderBase.getData();
          localScriptReaderBase.getCurrentTable().insertNoCheckFromLog(localSession2, arrayOfObject);
          break;
        case 2:
          arrayOfObject = localScriptReaderBase.getData();
          localScriptReaderBase.getCurrentTable().deleteNoCheckFromLog(localSession2, arrayOfObject);
          break;
        case 7:
          localSession2.setSchema(localScriptReaderBase.getCurrentSchema());
        case 6:
        }
        if (!localSession2.isClosed())
          continue;
        localIntKeyHashMap.remove(i);
      }
    }
    catch (Throwable localThrowable)
    {
      if (!(localThrowable instanceof EOFException))
      {
        if ((localThrowable instanceof OutOfMemoryError))
        {
          str = "out of memory processing " + paramString + " line: " + localScriptReaderBase.getLineNumber();
          paramDatabase.logger.appLog.logContext(SimpleLog.LOG_ERROR, str);
          throw Trace.error(72);
        }
        String str = paramString + " line: " + localScriptReaderBase.getLineNumber() + " " + localThrowable.toString();
        paramDatabase.logger.appLog.logContext(SimpleLog.LOG_ERROR, str);
      }
    }
    finally
    {
      if (localScriptReaderBase != null)
        localScriptReaderBase.close();
      paramDatabase.getSessionManager().closeAllSessions();
      paramDatabase.setReferentialIntegrity(true);
    }
  }
View Full Code Here

Examples of org.hsqldb_voltpatches.scriptio.ScriptReaderBase

    /**
     * Performs all the commands in the .script file.
     */
    private void processScript() {

        ScriptReaderBase scr = null;

        try {
            if (database.isFilesInJar()
                    || fa.isStreamElement(scriptFileName)) {
                scr = ScriptReaderBase.newScriptReader(database,
                                                       scriptFileName,
                                                       scriptFormat);

                Session session =
                    database.sessionManager.getSysSessionForScript(database);

                scr.readAll(session);
                scr.close();
            }
        } catch (Throwable e) {
            if (scr != null) {
                scr.close();

                if (cache != null) {
                    cache.close(false);
                }

View Full Code Here

Examples of org.hsqldb_voltpatches.scriptio.ScriptReaderBase

        Session       current    = null;
        int           currentId  = 0;

        database.setReferentialIntegrity(false);

        ScriptReaderBase scr = null;
        String           statement;
        int              statementType;

        try {
            StopWatch sw = new StopWatch();

            scr = ScriptReaderBase.newScriptReader(database, logFilename,
                                                   logType);

            while (scr.readLoggedStatement(current)) {
                int sessionId = scr.getSessionNumber();

                if (current == null || currentId != sessionId) {
                    currentId = sessionId;
                    current   = (Session) sessionMap.get(currentId);

                    if (current == null) {
                        current =
                            database.getSessionManager().newSession(database,
                                database.getUserManager().getSysUser(), false,
                                true, 0);

                        sessionMap.put(currentId, current);
                    }
                }

                if (current.isClosed()) {
                    sessionMap.remove(currentId);

                    continue;
                }

                Result result = null;

                statementType = scr.getStatementType();

                switch (statementType) {

                    case ScriptReaderBase.ANY_STATEMENT :
                        statement = scr.getLoggedStatement();
                        result    = current.executeDirectStatement(statement);

                        if (result != null && result.isError()) {
                            if (result.getException() != null) {
                                throw result.getException();
                            }

                            throw Error.error(result);
                        }
                        break;

                    case ScriptReaderBase.SEQUENCE_STATEMENT :
                        scr.getCurrentSequence().reset(scr.getSequenceValue());
                        break;

                    case ScriptReaderBase.COMMIT_STATEMENT :
                        current.commit(false);
                        break;

                    case ScriptReaderBase.INSERT_STATEMENT : {
                        current.beginAction(null);

                        Object[] data = scr.getData();

                        scr.getCurrentTable().insertNoCheckFromLog(current,
                                data);
                        current.endAction(Result.updateOneResult);

                        break;
                    }
                    case ScriptReaderBase.DELETE_STATEMENT : {
                        current.beginAction(null);

                        Object[] data = scr.getData();

                        scr.getCurrentTable().deleteNoCheckFromLog(current,
                                data);
                        current.endAction(Result.updateOneResult);

                        break;
                    }
                    case ScriptReaderBase.SET_SCHEMA_STATEMENT : {
                        current.setSchema(scr.getCurrentSchema());
                    }
                }

                if (current.isClosed()) {
                    sessionMap.remove(currentId);
                }
            }
        } catch (Throwable e) {
            String message;

            // catch out-of-memory errors and terminate
            if (e instanceof EOFException) {

                // end of file - normal end
            } else if (e instanceof OutOfMemoryError) {
                message = "out of memory processing " + logFilename
                          + " line: " + scr.getLineNumber();

                database.logger.appLog.logContext(SimpleLog.LOG_ERROR,
                                                  message);

                throw Error.error(ErrorCode.OUT_OF_MEMORY);
            } else {

                // stop processing on bad log line
                message = logFilename + " line: " + scr.getLineNumber() + " "
                          + e.toString();

                database.logger.appLog.logContext(SimpleLog.LOG_ERROR,
                                                  message);
            }
        } finally {
            if (scr != null) {
                scr.close();
            }

            database.getSessionManager().closeAllSessions();
            database.setReferentialIntegrity(true);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.