Package java.sql

Examples of java.sql.SQLException$InternalIterator


      out.println(sql);
     
      Throwable answer = t;
      if (t instanceof TeiidSQLException) {
        TeiidSQLException sqle = (TeiidSQLException) t;
        SQLException se = sqle.getNextException();
        if (se != null) {
          SQLException s = null;
          while( (s = se.getNextException()) != null) {
            se = s;
          }
         
          answer = se;
View Full Code Here


    }
   
    public Batch requestBatch(int beginRow) throws SQLException {
      batchCalls.add(beginRow);
      if (throwException) {
        throw new SQLException();
      }
          boolean isLast = false;
          int endRow = beginRow + 9;
          if (beginRow%10==0) {
            endRow = beginRow - 9;
View Full Code Here

    TeiidSQLException e = new TeiidSQLException();
    String sqlState = e.getSQLState();
    Throwable cause = e.getCause();
    int errorCode = e.getErrorCode();
    Throwable nestedException = e.getCause();
    SQLException nextException = e.getNextException();

    assertTrue(
        "Expected MMSQLException.getSQLState() to return <null> but got \"" //$NON-NLS-1$
            + sqlState + "\" instead.", sqlState == null); //$NON-NLS-1$
    assertTrue(
        "Expected MMSQLException.getCause() to return <null> but got [" //$NON-NLS-1$
            + (cause != null ? cause.getClass().getName()
                : "<unknown>") + "] instead.", cause == null); //$NON-NLS-1$ //$NON-NLS-2$
    assertTrue(
        "Expected MMSQLException.getErrorCode() to return [0] but got [" //$NON-NLS-1$
            + errorCode + "] instead.", errorCode == 0); //$NON-NLS-1$
    assertTrue(
        "Expected MMSQLException.getNestedException() to return <null> but got [" //$NON-NLS-1$
            + (nestedException != null ? nestedException.getClass()
                .getName() : "<unknown>") + "] instead.", //$NON-NLS-1$ //$NON-NLS-2$
        nestedException == null);
    assertTrue(
        "Expected MMSQLException.getNextException() to return <null> but got a SQLException with message \"" //$NON-NLS-1$
            + (nextException != null ? nextException.getMessage()
                : "") + "\" instead.", nextException == null); //$NON-NLS-1$ //$NON-NLS-2$
  }
View Full Code Here

    }
    String sqlState = e.getSQLState();
    Throwable cause = e.getCause();
    int errorCode = e.getErrorCode();
    Throwable nestedException = e.getCause();
    SQLException nextException = e.getNextException();

    assertTrue("Expected MMSQLException.getSQLState() to return \"" //$NON-NLS-1$
        + esqlState + "\" but got \"" + sqlState + "\" instead.", //$NON-NLS-1$ //$NON-NLS-2$
        sqlState.compareTo(esqlState) == 0);
    assertTrue("Expected MMSQLException.getCause() to return [" //$NON-NLS-1$
        + (ecause != null ? ecause.getClass().getName() : "<null>") //$NON-NLS-1$
        + "] but got [" //$NON-NLS-1$
        + (cause != null ? cause.getClass().getName() : "<unknown>") //$NON-NLS-1$
        + "] instead.", cause == ecause); //$NON-NLS-1$
    assertTrue(
        "Expected MMSQLException.getErrorCode() to return [0] but got [" //$NON-NLS-1$
            + errorCode + "] instead.", errorCode == 0); //$NON-NLS-1$
    assertTrue("Expected MMSQLException.getNestedException() to return [" //$NON-NLS-1$
        + (ecause != null ? ecause.getClass().getName() : "<null>") //$NON-NLS-1$
        + "] but got [" //$NON-NLS-1$
        + (nestedException != null ? nestedException.getClass()
            .getName() : "<unknown>") + "] instead.", //$NON-NLS-1$ //$NON-NLS-2$
        nestedException == ecause);
    assertTrue(
        "Expected MMSQLException.getNextException() to return <null> but got a SQLException with message \"" //$NON-NLS-1$
            + (nextException != null ? nextException.getMessage()
                : "") + "\" instead.", nextException == null); //$NON-NLS-1$ //$NON-NLS-2$
    return e;
    }
View Full Code Here

       
        assertEquals(exception, TeiidSQLException.create(exception));
    }
   
    public void testCreateFromSQLException() {
        SQLException sqlexception = new SQLException("foo", "21"); //$NON-NLS-1$ //$NON-NLS-2$
       
        SQLException nested = new SQLException("bar"); //$NON-NLS-1$
       
        sqlexception.setNextException(nested);
       
        String message = "top level message"; //$NON-NLS-1$
       
        TeiidSQLException exception = TeiidSQLException.create(sqlexception, message);
       
        assertEquals(exception.getMessage(), message);
        assertEquals(exception.getSQLState(), sqlexception.getSQLState());       
        assertEquals(exception.getNextException().getMessage(), sqlexception.getMessage());
        assertEquals(exception.getNextException().getNextException().getMessage(), nested.getMessage());
    }
View Full Code Here

  }
 
  @Test public void testDeserializationUnknownChildException() throws Exception {
    ClassLoader cl = new URLClassLoader(new URL[] {UnitTestUtil.getTestDataFile("test.jar").toURI().toURL()}); //$NON-NLS-1$
    Exception obj = (Exception)ReflectionHelper.create("test.UnknownException", null, cl); //$NON-NLS-1$
    obj.initCause(new SQLException("something bad happended")); //$NON-NLS-1$
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(new ExceptionHolder(new BadException2(obj, "I have foreign exception embedded in me"))); //$NON-NLS-1$
        oos.flush();
View Full Code Here

        buff.append(")");
    }

    private void execute(String sql) throws SQLException {
        String expected = null;
        SQLException e = null;
        for (Statement s : dbs) {
            try {
                boolean result = s.execute(sql);
                if (result) {
                    String data = getResult(s.getResultSet());
View Full Code Here

            if (running) {
                println("stopping (force)...");
                for (StackTraceElement e : mainThread.getStackTrace()) {
                    System.out.println(e.toString());
                }
                mainThread.stop(new SQLException("stop"));
            }
        }
    }
View Full Code Here

        if (t instanceof BatchUpdateException) {
            // do nothing
        } else if (t.getClass().getName().indexOf("SQLClientInfoException") >= 0) {
            // do nothing
        } else if (t instanceof SQLException) {
            SQLException s = (SQLException) t;
            int errorCode = s.getErrorCode();
            if (errorCode == 0) {
                printError(seed, id, s);
            } else if (errorCode == ErrorCode.OBJECT_CLOSED) {
                if (objectId >= 0 && objects.size() > 0) {
                    // TODO at least call a few more times after close - maybe
View Full Code Here

            session.prepare("shutdown immediately").update();
            database.removeSession(null);
            // everything OK - return
            return;
        } catch (DbException e) {
            SQLException e2 = DbException.toSQLException(e);
            int errorCode = e2.getErrorCode();
            if (errorCode == ErrorCode.WRONG_USER_OR_PASSWORD) {
                return;
            } else if (errorCode == ErrorCode.FILE_ENCRYPTION_ERROR_1) {
                return;
            }
View Full Code Here

TOP

Related Classes of java.sql.SQLException$InternalIterator

Copyright © 2018 www.massapicom. 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.