java/dbloader/src/main/java/be/bosa/dt/best/dbloader/PostGisLoader.java
/**
	 * Load addresses
	 * 
	 * @param prep prepared statement
	 * @param xmlPath XML BeST directory
	 * @param reg region code
	 * @throws SQLException 
	 */
Load addresses

@param prep prepared statement
@param xmlPath XML BeST directory
@param reg region code
@throws SQLException
Load addresses @param prep prepared statement @param xmlPath XML BeST directory @param reg region code @throws SQLException
private void loadAddresses(PreparedStatement prep, Path xmlPath, BestRegion reg) throws SQLException {
		LOG.log(Level.INFO, "Starting addresses {0}", reg.getName());
		int cnt = 0;
/*
		GeoCoder geoCoder = null;
		try {
		} catch(Exception e) {
			throw new SQLException("Could not init coder", e);
		}
*/
		AddressReader reader = new AddressReader();
		Stream<Address> addresses = reader.read(reg, xmlPath);
		Iterator<Address> iter = addresses.iterator();
		while (iter.hasNext()) {
			Address a = iter.next();
			Geopoint p = a.getPoint();
			String geom = encodePoint(p);
			prep.setString(1, NsConverter.addressEncode(a.getIDVersion()));
			prep.setString(2, NsConverter.municipalityEncode(a.getCity().getIDVersion()));
			prep.setString(3, null);
			prep.setString(4, NsConverter.streetEncode(a.getStreet().getIDVersion()));
			prep.setString(5, NsConverter.postalEncode(a.getPostal().getIDVersion()));
			prep.setString(6, a.getNumber());
			prep.setString(7, a.getBox());
			prep.setObject(8, a.getStatus(), Types.OTHER);
			prep.setObject(9, a.getFromDate(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.setObject(10, a.getTillDate(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.setObject(11, a.getBeginLife(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.setObject(12, a.getEndLife(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.setObject(13, geom, Types.OTHER);
			prep.setBoolean(14, false);
			prep.addBatch();
			if (++cnt % 10_000 == 0) {
				prep.executeBatch();
				LOG.log(Level.INFO, "Inserted {0}", cnt);
			}
		}
		prep.executeBatch();
		LOG.log(Level.INFO, "Inserted {0}", cnt);
	}
private void loadAddresses ( PreparedStatement prep , Path xmlPath , BestRegion reg ) throws SQLException { LOG . log ( Level . INFO , "Starting addresses {0}" , reg . getName ( ) ) ; int cnt = 0 ; /*
		GeoCoder geoCoder = null;
		try {
		
		} catch(Exception e) {
			throw new SQLException("Could not init coder", e);
		}
*/ AddressReader reader = new AddressReader ( ) ; Stream < Address > addresses = reader . read ( reg , xmlPath ) ; Iterator < Address > iter = addresses . iterator ( ) ; while ( iter . hasNext ( ) ) { Address a = iter . next ( ) ; Geopoint p = a . getPoint ( ) ; String geom = encodePoint ( p ) ; prep . setString ( 1 , NsConverter . addressEncode ( a . getIDVersion ( ) ) ) ; prep . setString ( 2 , NsConverter . municipalityEncode ( a . getCity ( ) . getIDVersion ( ) ) ) ; prep . setString ( 3 , null ) ; prep . setString ( 4 , NsConverter . streetEncode ( a . getStreet ( ) . getIDVersion ( ) ) ) ; prep . setString ( 5 , NsConverter . postalEncode ( a . getPostal ( ) . getIDVersion ( ) ) ) ; prep . setString ( 6 , a . getNumber ( ) ) ; prep . setString ( 7 , a . getBox ( ) ) ; prep . setObject ( 8 , a . getStatus ( ) , Types . OTHER ) ; prep . setObject ( 9 , a . getFromDate ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . setObject ( 10 , a . getTillDate ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . setObject ( 11 , a . getBeginLife ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . setObject ( 12 , a . getEndLife ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . setObject ( 13 , geom , Types . OTHER ) ; prep . setBoolean ( 14 , false ) ; prep . addBatch ( ) ; if ( ++ cnt % 10_000 == 0 ) { prep . executeBatch ( ) ; LOG . log ( Level . INFO , "Inserted {0}" , cnt ) ; } } prep . executeBatch ( ) ; LOG . log ( Level . INFO , "Inserted {0}" , cnt ) ; }
Load addresses
Load addresses
// insert per 10_000 records // insert per 10_000 records