/** * @see org.teiid.jdbc.api.SQLException#isUsageErrorState() * @since 4.3 */ public boolean isUsageErrorState() { return SQLStates.isUsageErrorState(getSQLState()); }
/** * @see org.teiid.jdbc.api.SQLException#isSystemErrorState() * @since 4.3 */ public boolean isSystemErrorState() { return SQLStates.isSystemErrorState(getSQLState()); }
/** * @see org.teiid.jdbc.api.SQLException#isSystemErrorState() * @since 4.3 */ public boolean isSystemErrorState() { return SQLStates.isSystemErrorState(getSQLState()); }
/** * @see org.teiid.jdbc.api.SQLException#isUsageErrorState() * @since 4.3 */ public boolean isUsageErrorState() { return SQLStates.isUsageErrorState(getSQLState()); }
@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)); }
throw new BatchUpdateException(e.getMessage(), ex.getSQLState(), ex.getErrorCode(), allUpdateCounts==null?new int[0]:allUpdateCounts, e); } catch (BatchUpdateException e) { if (allUpdateCounts == null) {
throw new BatchUpdateException(e.getMessage(), ex.getSQLState(), ex.getErrorCode(), allUpdateCounts==null?new int[0]:allUpdateCounts, e); } catch (BatchUpdateException e) { if (allUpdateCounts == null) {
@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 {
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 testMMSQLException() { 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$ }
private TeiidSQLException testCreateThrowable(Throwable ecause, String esqlState) { TeiidSQLException e = TeiidSQLException.create(ecause); if (ecause.getClass() == TeiidSQLException.class) { ecause = null; } String sqlState = e.getSQLState(); Throwable cause = e.getCause(); int errorCode = e.getErrorCode(); Throwable nestedException = e.getCause(); SQLException nextException = e.getNextException(); assertEquals(esqlState, sqlState); assertEquals(ecause, cause); assertEquals(0, errorCode); assertEquals(nestedException, ecause); assertNull(nextException); return e; }
@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()); } }
TeiidSQLException tse = TeiidSQLException.create(e); GroupSymbol gs = new GroupSymbol(program.getExceptionGroup()); this.currentVarContext.setValue(exceptionSymbol(gs, 0), tse.getSQLState()); this.currentVarContext.setValue(exceptionSymbol(gs, 1), tse.getErrorCode()); this.currentVarContext.setValue(exceptionSymbol(gs, 2), tse.getTeiidCode());
TeiidSQLException tse = TeiidSQLException.create(e); GroupSymbol gs = new GroupSymbol(program.getExceptionGroup()); this.currentVarContext.setValue(exceptionSymbol(gs, 0), tse.getSQLState()); this.currentVarContext.setValue(exceptionSymbol(gs, 1), tse.getErrorCode()); this.currentVarContext.setValue(exceptionSymbol(gs, 2), tse.getTeiidCode());
this.currentVarContext.setValue(exceptionSymbol(gs, 0), tse.getSQLState()); this.currentVarContext.setValue(exceptionSymbol(gs, 1), tse.getErrorCode()); this.currentVarContext.setValue(exceptionSymbol(gs, 2), tse.getTeiidCode());