assertEquals("Invalid SQL state.", SqlStateCode.CONVERSION_FAILED, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.CONVERSION_FAILED, e.getErrorCode());
assertEquals("Invalid SQL state.", SqlStateCode.CONVERSION_FAILED, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.CONVERSION_FAILED, e.getErrorCode());
/** * Test error code for the case when error is caused on batch execution. * @throws SQLException if failed. */ @Test public void testBatchUpdateException() throws SQLException { try (final Connection conn = getConnection()) { try (Statement stmt = conn.createStatement()) { stmt.executeUpdate("CREATE TABLE test (id int primary key, val varchar)"); stmt.addBatch("insert into test (id, val) values (1, 'val1')"); stmt.addBatch("insert into test (id, val) values (2, 'val2')"); stmt.addBatch("insert into test (id1, val1) values (3, 'val3')"); stmt.executeBatch(); fail("BatchUpdateException is expected"); } catch (BatchUpdateException e) { assertEquals(3, e.getUpdateCounts().length); assertArrayEquals("", new int[] {1, 1, Statement.EXECUTE_FAILED}, e.getUpdateCounts()); assertEquals("42000", e.getSQLState()); assertTrue("Unexpected error message: " + e.getMessage(), e.getMessage() != null && e.getMessage().contains("Failed to parse query. Column \"ID1\" not found")); } } }
assertEquals("Invalid SQL state.", SqlStateCode.INTERNAL_ERROR, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.UNKNOWN, e.getErrorCode());
assertEquals("Invalid SQL state.", SqlStateCode.INTERNAL_ERROR, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.UNKNOWN, e.getErrorCode());
assertEquals("Invalid SQL state.", SqlStateCode.PARSING_EXCEPTION, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.STMT_TYPE_MISMATCH, e.getErrorCode());
assertEquals("Invalid SQL state.", SqlStateCode.CONVERSION_FAILED, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.CONVERSION_FAILED, e.getErrorCode());
assertEquals("Invalid SQL state.", SqlStateCode.CONSTRAINT_VIOLATION, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.DUPLICATE_KEY, e.getErrorCode());
assertEquals("Invalid SQL state.", SqlStateCode.CONVERSION_FAILED, e.getSQLState()); assertEquals("Invalid error code.", IgniteQueryErrorCode.CONVERSION_FAILED, e.getErrorCode());
aiupdateCounts = bue.getUpdateCounts(); logger.error("SQLException: " + bue.getMessage()); logger.error("SQLState: " + bue.getSQLState()); logger.error("Message: " + bue.getMessage()); logger.error("Vendor: " + bue.getErrorCode());
aiupdateCounts = bue.getUpdateCounts(); logger.error("SQLException: " + bue.getMessage()); logger.error("SQLState: " + bue.getSQLState()); logger.error("Message: " + bue.getMessage()); logger.error("Vendor: " + bue.getErrorCode());
throw new BatchUpdateException(e.getMessage(), e.getSQLState(), e.getErrorCode(), allUpdateCounts, e);
throw new BatchUpdateException(e.getMessage(), e.getSQLState(), e.getErrorCode(), allUpdateCounts, e);