Java 8 BatchUpdateException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 BatchUpdateException class.

This code example shows how to use the following methods:setNextException
        .getUpdateCounts() ); 
  } 
 
  @Test
  public void testCreateKettleDatabaseBatchExceptionConstructsExceptionList() { 
    BatchUpdateException root = new BatchUpdateException();
    SQLException next = new SQLException();
    SQLException next2 = new SQLException();
    root.setNextException( next );
    next.setNextException( next2 );
    List<Exception> exceptionList = Database.createKettleDatabaseBatchException( "", root ).getExceptionsList();
    assertEquals( 2, exceptionList.size() );
    assertEquals( next, exceptionList.get( 0 ) );
    assertEquals( next2, exceptionList.get( 1 ) );
  } 
 
  @Test( expected = KettleDatabaseBatchException.class )
  public void testInsertRowWithBatchAlwaysThrowsKettleBatchException() throws KettleDatabaseException, SQLException {
    DatabaseMeta mockDatabaseMeta = mock( DatabaseMeta.class );
    when( mockDatabaseMeta.supportsBatchUpdates() ).thenReturn( true );
6
CodeRank
This code example shows how to use the following methods:getUpdateCounts
            // The executeBatch() method will result in a 
            // BatchUpdateException 
            prep.executeBatch();
        } catch (BatchUpdateException b) {
            trace("expected BatchUpdateException"); 
            batchUpdates = b.getUpdateCounts();
            buCountLen = batchUpdates.length;
        } 
        if (buCountLen == 1) {
            trace("no continued updates - OK"); 
            return; 
        } else if (buCountLen == 3) {
            trace("Driver supports continued updates."); 
            // Check to see if the third row from the batch was added 
            String query = COFFEE_SELECT_CONTINUED;
            trace("Query is: " + query);
            ResultSet rs = stat.executeQuery(query);
            rs.next();
            int count = rs.getInt(1);
            rs.close();
4
CodeRank
This code example shows how to use the following methods:getNextException
			connection.commit();
 
		} catch (Exception e) {
			if (e instanceof BatchUpdateException) {
				BatchUpdateException bue = (BatchUpdateException) e;
				bue.getNextException().printStackTrace();
			} 
			e.printStackTrace();
			fail(e.getMessage());
		} 
	} 
 
	// @Test 
	public void inserUserAndRoles() { 
		try { 
			assertFalse(connection.isClosed());
			String sql = "insert into users(username,password,first_name,last_name) values(?,?,?,?)";
			PreparedStatement prepareStatement = connection
					.prepareStatement(sql);
 
4
CodeRank
This code example shows how to use the following methods:
     * update counts. 
     */ 
    protected   BatchUpdateException   newBatchUpdateException 
        ( String message, String sqlState, int errorCode, long[] updateCounts, SqlException cause ) 
    { 
        return new BatchUpdateException( 
            message, 
            sqlState, 
            errorCode, 
            updateCounts, 
            cause); 
    } 
 
    /** 
     * Returns a PreparedStatement. 
     */ 
    public ClientPreparedStatement newPreparedStatement(Agent agent, 
            ClientConnection connection, 
            String sql,Section section,ClientPooledConnection cpc)  
            throws SqlException { 
4
CodeRank
This code example shows how to use the following methods:getNextException
		try { 
			List<Vehicle> vehicles = cta.getVehicles(new String[] {"22","50","77","76","36","92","81","2","55","6"});//cta.getVehicles(file);
			try { 
				cta.insertVehicles(connection, vehicles);
			} catch (BatchUpdateException e) {
				System.err.println(e.getNextException());
			} 
		} catch (IOException e) {
				System.err.println(e);
				//System.err.println(readFile(file)); 
		} 
		 
		connection.close();
	} 
} 
4
CodeRank
This code example shows how to use the following methods:getNextException
		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);
		} 
	} 
	 
	protected void addContentAttributeRoleRecord(String id, IApsEntity entity, String query, Connection conn) throws ApsSystemException {
		PreparedStatement stat = null;
		try { 
			stat = conn.prepareStatement(query);
			super.addEntityAttributeRoleRecord(id, entity, stat);
3
CodeRank
This code example shows how to use the following methods:getUpdateCounts
            // BatchUpdateException 
            prep.executeBatch();
        } 
        catch (final BatchUpdateException b) {
            trace("expected BatchUpdateException"); 
            batchUpdates = b.getUpdateCounts();
            buCountLen = batchUpdates.length;
        } 
        if (buCountLen == 1) {
            trace("no continued updates - OK"); 
            return; 
        } 
        else if (buCountLen == 3) {
            trace("Driver supports continued updates."); 
            // Check to see if the third row from the batch was added 
            final String query = COFFEE_SELECT_CONTINUED;
            trace("Query is: " + query);
            final ResultSet rs = stat.executeQuery(query);
            rs.next();
            final int count = rs.getInt(1);
3
CodeRank
This code example shows how to use the following methods:getUpdateCounts
            // The executeBatch() method will result in a 
            // BatchUpdateException 
            prep.executeBatch();
        } 
        catch (final BatchUpdateException b) {
            batchUpdates = b.getUpdateCounts();
            buCountLen = batchUpdates.length;
        } 
 
        if (buCountLen == 3) {
 
            // Check to see if the third row from the batch was added 
            final String query = COFFEE_SELECT_CONTINUED;
            final ResultSet rs = statement.executeQuery(query);
            rs.next();
            final int count = rs.getInt(1);
            rs.close();
            statement.close();
            // Make sure that we have the correct error code for 
            // the failed update. 
3
CodeRank
This code example shows how to use the following methods:getUpdateCounts
            // The executeBatch() method will result in a 
            // BatchUpdateException 
            prep.executeBatch();
        } catch (BatchUpdateException b) {
            trace("expected BatchUpdateException"); 
            batchUpdates = b.getUpdateCounts();
            buCountLen = batchUpdates.length;
        } 
        if (buCountLen == 1) {
            trace("no continued updates - OK"); 
            return; 
        } else if (buCountLen == 3) {
            trace("Driver supports continued updates."); 
            // Check to see if the third row from the batch was added 
            String query = COFFEE_SELECT_CONTINUED;
            trace("Query is: " + query);
            ResultSet rs = stat.executeQuery(query);
            rs.next();
            int count = rs.getInt(1);
            rs.close();
3
CodeRank
This code example shows how to use the following methods:getNextException
		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);
		} 
	} 
	 
	@Override 
	public List<String> getContentUtilizers(String contentId) {
		List<String> contentIds = null;
		try { 
			contentIds = this.getUtilizers(contentId, LOAD_REFERENCED_CONTENTS_FOR_CONTENT);
3
CodeRank
See Code Examples for Java 8 BatchUpdateException Methods: