private TeiidSQLException(SQLException ex, String message, boolean addChildren) { super(message, ex.getSQLState() == null ? SQLStates.DEFAULT : ex.getSQLState(), ex.getErrorCode(), ex); if (addChildren) { SQLException childException = ex.getNextException(); // this a child to the SQLException constructed from reason while (childException != null) { if (childException instanceof TeiidSQLException) { super.setNextException(ex); break; } super.setNextException(new TeiidSQLException(childException, getMessage(childException, null),false)); childException = childException.getNextException(); } } }
private TeiidSQLException(SQLException ex, String message, boolean addChildren) { super(message, ex.getSQLState() == null ? SQLStates.DEFAULT : ex.getSQLState(), ex.getErrorCode(), ex); if (addChildren) { SQLException childException = ex.getNextException(); // this a child to the SQLException constructed from reason while (childException != null) { if (childException instanceof TeiidSQLException) { super.setNextException(ex); break; } super.setNextException(new TeiidSQLException(childException, getMessage(childException, null),false)); childException = childException.getNextException(); } } }
/** * @see java.lang.Object#toString() */ public String toString() { try { return buildURL().getJDBCURL(); } catch (TeiidSQLException e) { return e.getMessage(); } }
/** * @see java.lang.Object#toString() */ public String toString() { try { return buildURL().getJDBCURL(); } catch (TeiidSQLException e) { return e.getMessage(); } }
public static TeiidSQLException create(Throwable exception, String message) { message = getMessage(exception, message); Throwable origException = exception; if (exception instanceof TeiidSQLException
public static TeiidSQLException create(Throwable exception, String message) { message = getMessage(exception, message); Throwable origException = exception; if (exception instanceof TeiidSQLException
} catch (TeiidSQLException e) { logger.log(Level.FINE, "Could not create connection", e); //$NON-NLS-1$ throw TeiidSQLException.create(e, e.getMessage());
} catch (TeiidSQLException e) { logger.log(Level.FINE, "Could not create connection", e); //$NON-NLS-1$ throw TeiidSQLException.create(e, e.getMessage());
@Test 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); exception.printStackTrace(); assertEquals(sqlexception, exception.getCause()); assertEquals(exception.getMessage(), message); assertEquals(exception.getSQLState(), sqlexception.getSQLState()); assertEquals(exception.getNextException().getMessage(), nested.getMessage()); } public static enum Event implements BundleUtil.Event {
@Test public void testCreateThrowable3() { TeiidSQLException e = testCreateThrowable( new TeiidException( new SocketTimeoutException( "A test MM Invalid Session Exception"), //$NON-NLS-1$ "Test MetaMatrixRuntimeException with a InvalidSessionException in it"), //$NON-NLS-1$ SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION); //test to ensure that wrapping mmsqlexceptions works TeiidSQLException e1 = TeiidSQLException.create(e, "new message"); //$NON-NLS-1$ assertEquals("new message", e1.getMessage()); //$NON-NLS-1$ testCreateThrowable(((TeiidSQLException)e1.getCause()).getCause(), SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION); }
BatchUpdateException batchUpdateException = new BatchUpdateException(exe.getMessage(), exe.getSQLState(), exe.getErrorCode(), updateCounts, exe); this.updateCounts=null; throw batchUpdateException;
BatchUpdateException batchUpdateException = new BatchUpdateException(exe.getMessage(), exe.getSQLState(), exe.getErrorCode(), updateCounts, exe); this.updateCounts=null; throw batchUpdateException;
@Test public void testCreate() { TeiidSQLException exception = TeiidSQLException.create(new Exception()); assertEquals(exception.getMessage(), Exception.class.getName()); assertNotNull(exception.getSQLState()); assertEquals(exception.getSQLState(), "38000"); //$NON-NLS-1$ assertEquals(exception, TeiidSQLException.create(exception)); }
@Test public void testMaxOpenStatements() throws SQLException { ConnectionImpl conn = getMMConnection(); for(int i = 0; i < 1000; i++){ conn.createStatement(); } try{ conn.createStatement(); fail("MaxOpenStatements not limited to required number."); } catch (TeiidSQLException ex){ assertThat(ex.getMessage(), CoreMatchers.containsString(JDBCPlugin.Event.TEIID20036.name())); } } }
@Test public void testExceptionHandling() throws Exception { String ddl = "create virtual procedure vproc (x integer) returns integer as begin " + "raise sqlexception 'hello world' sqlstate 'abc', 1;" + "exception e " + "raise sqlwarning sqlexception 'caught' chain e.exception; " + "\"return\" = 1;"+ "end;"; TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl); String sql = "call vproc(1)"; //$NON-NLS-1$ ProcessorPlan plan = getProcedurePlan(sql, tm); HardcodedDataManager dataManager = new HardcodedDataManager(tm); helpTestProcess(plan, new List[] {Arrays.asList(1)}, dataManager, tm); TeiidSQLException tse = (TeiidSQLException)plan.getContext().getAndClearWarnings().get(0); assertEquals("caught", tse.getMessage()); assertEquals("hello world", tse.getCause().getMessage()); }
@Test public void testExceptionAndWarning() throws Exception { String ddl = "create virtual procedure vproc (x integer) returns integer as begin declare exception e = sqlexception 'hello'; raise sqlwarning e; raise sqlexception 'hello world' sqlstate 'abc', 1 chain e; end;"; TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl); String sql = "call vproc(1)"; //$NON-NLS-1$ ProcessorPlan plan = getProcedurePlan(sql, tm); HardcodedDataManager dataManager = new HardcodedDataManager(tm); try { helpTestProcess(plan, null, dataManager, tm); fail(); } catch (TeiidProcessingException e) { TeiidSQLException tsw = (TeiidSQLException) plan.getContext().getAndClearWarnings().get(0); assertEquals("hello", tsw.getMessage()); assertEquals(e.getCause().getCause(), tsw); TeiidSQLException tse = (TeiidSQLException)e.getCause(); assertEquals("hello world", tse.getMessage()); assertEquals("abc", tse.getSQLState()); assertEquals(1, tse.getErrorCode()); } }