/** * Inserts the test data via a direct route (JDBC). */ public void prepareTest() { try { dataSourceUtils.insertTestData( testData ); } catch (BatchUpdateException e) { throw new RuntimeException( e.getNextException() ); } catch (SQLException e) { throw new RuntimeException( e ); } }
private static SQLException findInterestingCause(SQLException e) { if (e instanceof BatchUpdateException) { BatchUpdateException b = (BatchUpdateException) e; logger.error(b.toString(), b); return b.getNextException(); } return e; }
private void addLabelGroup(String key, ApsProperties labels, Connection conn) throws ApsSystemException { PreparedStatement stat = null; try { stat = conn.prepareStatement(ADD_LABEL); Iterator<Object> labelKeysIter = labels.keySet().iterator(); while (labelKeysIter.hasNext()) { String labelLangCode = (String) labelKeysIter.next(); String label = labels.getProperty(labelLangCode); stat.setString(1, key); stat.setString(2, labelLangCode); stat.setString(3, label); stat.addBatch(); stat.clearParameters(); } stat.executeBatch(); } catch (BatchUpdateException e) { _logger.error("Error adding a new label record", e.getNextException()); throw new RuntimeException("Error adding a new label record", e.getNextException()); //processDaoException(e.getNextException(), "Error adding a new label record", "addLabel"); } catch (Throwable t) { _logger.error("Error while adding a new label", t); throw new RuntimeException("Error while adding a new label", t); //processDaoException(t, "Error while adding a new label", "addLabel"); } finally { closeDaoResources(null, stat); } }
/** * Log a batch update exception with values. */ static void logBatchUpdateException(BatchUpdateException bue, String sqlQuery, List<? extends List<?>> parameters) { int i = 0; StringBuilder errorBuilder = new StringBuilder(); for (int code : bue.getUpdateCounts()) { if (code == Statement.EXECUTE_FAILED) { List<?> rowData = parameters.get(i); errorBuilder.append("Batch update failed with query '"); errorBuilder.append(sqlQuery); errorBuilder.append("' with values ("); int o = 0; for (Object value : rowData) { if (o++ != 0) { errorBuilder.append(", "); } if (value instanceof byte[]) { errorBuilder.append(StringUtils.hex((byte[]) value)); } else { errorBuilder.append(value); } } errorBuilder.append(')'); } i++; } Exception ex = bue.getNextException() != null ? bue.getNextException() : bue; LOGGER.error(errorBuilder.toString(), ex); }
} catch (BatchUpdateException e) { logger.error("Error adding relation for record {}", recordId, e); throw new RuntimeException("Error adding relation for record - " + recordId, e.getNextException()); } catch (Throwable t) { logger.error("Error adding relations for record {}", recordId, t);
private void addLogRecordRelations(int recordId, ActivityStreamInfo asi, Connection conn) { if (asi == null) { return; } List<String> groups = asi.getGroups(); if (null == groups || groups.isEmpty()) { return; } Set<String> codes = new HashSet<String>(groups); Iterator<String> iterator = codes.iterator(); PreparedStatement stat = null; try { stat = conn.prepareStatement(ADD_LOG_RECORD_RELATION); while (iterator.hasNext()) { String groupCode = iterator.next(); stat.setInt(1, recordId); stat.setString(2, groupCode); stat.addBatch(); stat.clearParameters(); } stat.executeBatch(); } catch (BatchUpdateException e) { processDaoException(e.getNextException(), "Error adding relations for record - " + recordId, "addLogRecordRelations"); } catch (Throwable t) { processDaoException(t, "Error adding relations for record - " + recordId, "addLogRecordRelations"); } finally { closeDaoResources(null, stat); } }
private void addLabelGroup(String key, ApsProperties labels, Connection conn) throws ApsSystemException { PreparedStatement stat = null; try { stat = conn.prepareStatement(ADD_LABEL); Iterator<Object> labelKeysIter = labels.keySet().iterator(); while (labelKeysIter.hasNext()) { String labelLangCode = (String) labelKeysIter.next(); String label = labels.getProperty(labelLangCode); stat.setString(1, key); stat.setString(2, labelLangCode); stat.setString(3, label); stat.addBatch(); stat.clearParameters(); } stat.executeBatch(); } catch (BatchUpdateException e) { processDaoException(e.getNextException(), "Error adding a new label record", "addLabel"); } catch (Throwable t) { processDaoException(t, "Error while adding a new label", "addLabel"); } finally { closeDaoResources(null, stat); } }
/** * Add a record in the table 'dataobjectrelations' for every resource, page, * other dataobject, role and category associated to the given dataobject). * * @param dataobject The current dataobject. * @param conn The connection to the database. * @throws ApsSystemException when connection error are detected. */ protected void addDataObjectRelationsRecord(DataObject dataobject, Connection conn) throws ApsSystemException { PreparedStatement stat = null; try { stat = conn.prepareStatement(ADD_DATAOBJECT_REL_RECORD); this.addCategoryRelationsRecord(dataobject, true, stat); this.addGroupRelationsRecord(dataobject, stat); EntityAttributeIterator attributeIter = new EntityAttributeIterator(dataobject); while (attributeIter.hasNext()) { AttributeInterface currAttribute = (AttributeInterface) attributeIter.next(); } stat.executeBatch(); } catch (BatchUpdateException e) { _logger.error("Error saving record into dataobjectrelations {}", dataobject.getId(), e.getNextException()); throw new RuntimeException("Error saving record into dataobjectrelations " + dataobject.getId(), e.getNextException()); } catch (Throwable t) { _logger.error("Error saving record into dataobjectrelations {}", dataobject.getId(), t); throw new RuntimeException("Error saving record into dataobjectrelations " + dataobject.getId(), t); } finally { closeDaoResources(null, stat); } }
protected void addWorkContentRelationsRecord(Content content, Connection conn) throws ApsSystemException{ PreparedStatement stat = null; try { stat = conn.prepareStatement(ADD_WORK_CONTENT_REL_RECORD); this.addCategoryRelationsRecord(content, false, stat); stat.executeBatch(); } catch (BatchUpdateException e) { processDaoException(e.getNextException(), "Errore in aggiunta record tabella workcontentrelations - " + content.getId(), "addContentRelationsRecord"); } catch (Throwable t) { processDaoException(t, "Errore in aggiunta record tabella workcontentrelations - " + content.getId(), "addContentRelationsRecord"); } finally { closeDaoResources(null, stat); } }
batchEx = (BatchUpdateException)e; if (batchEx.getNextException() != null) { e = batchEx.getNextException();
if (e instanceof BatchUpdateException) { BatchUpdateException bue = (BatchUpdateException) e; if (e.getCause() == null && bue.getNextException() != null) { e.initCause(bue.getNextException());
batchEx = (BatchUpdateException)e; if (batchEx.getNextException() != null) { e = batchEx.getNextException();
batchEx = (BatchUpdateException)e; if (batchEx.getNextException() != null) { e = batchEx.getNextException();
processDaoException(e.getNextException(), "Errore in aggiunta record tabella contentrelations - " + content.getId(), "addContentRelationsRecord"); } catch (Throwable t) {
@Override public void populate(Connection connection) throws SQLException { LOGGER.debug("populating"); StopWatch sw = new StopWatch("DbUnitDatabasePopulator"); DatabaseOperation operation = phase.getOperation(dataSetConfiguration); try { IDataSet dataSet = decorateDataSetIfNeeded(dataSetConfiguration.getDataSet(), dataSetConfiguration.getDecorators()); String schema = dataSetConfiguration.getSchema(); DatabaseConnection databaseConnection = getDatabaseConnection(connection, schema, dataSetConfiguration); sw.start("populating"); operation.execute(databaseConnection, dataSet); sw.stop(); LOGGER.debug(sw.prettyPrint()); } catch (BatchUpdateException e) { LOGGER.error("BatchUpdateException while loading dataset", e); LOGGER.error("Caused by : ", e.getNextException()); throw e; } catch (DatabaseUnitException e) { throw new DbUnitException(e); } catch (IOException e) { throw new DbUnitException(e); } }
SQLException sqlEx = ((BatchUpdateException)ex).getNextException();
Tr.event(tc, " Statement " + i + ":" + updateCounts[i]); SQLException nextex = buex.getNextException(); while (nextex != null) { sqlErrorCode = nextex.getErrorCode();