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

@param prep prepared statement
@param xmlPath XML BeST directory
@param reg region code
@throws SQLException
Load streets @param prep prepared statement @param xmlPath XML BeST directory @param reg region code @throws SQLException
private void loadStreets(PreparedStatement prep, Path xmlPath, BestRegion reg) throws SQLException {
		LOG.log(Level.INFO, "Starting streets {0} ", reg.getName());
		int cnt = 0;
		StreetnameReader reader = new StreetnameReader();
		Stream<Street> streets = reader.read(reg, xmlPath);
		Iterator<Street> iter = streets.iterator();
		while (iter.hasNext()) {
			Street a = iter.next();
			prep.setString(1, NsConverter.streetEncode(a.getIDVersion()));
			prep.setString(2, NsConverter.municipalityEncode(a.getCity().getIDVersion()));
			prep.setString(3, a.getName("nl"));
			prep.setString(4, a.getName("fr"));
			prep.setString(5, a.getName("de"));
			prep.setObject(6, a.getStatus(), Types.OTHER);
			prep.setObject(7, a.getFromDate(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.setObject(8, a.getTillDate(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.setObject(9, a.getBeginLife(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.setObject(10, a.getEndLife(), Types.TIMESTAMP_WITH_TIMEZONE);
			prep.addBatch();
			if (++cnt % 10_000 == 0) {
				prep.executeBatch();
				LOG.log(Level.INFO, "Inserted {0}", cnt);
			}
		}
		prep.executeBatch();
	}
private void loadStreets ( PreparedStatement prep , Path xmlPath , BestRegion reg ) throws SQLException { LOG . log ( Level . INFO , "Starting streets {0} " , reg . getName ( ) ) ; int cnt = 0 ; StreetnameReader reader = new StreetnameReader ( ) ; Stream < Street > streets = reader . read ( reg , xmlPath ) ; Iterator < Street > iter = streets . iterator ( ) ; while ( iter . hasNext ( ) ) { Street a = iter . next ( ) ; prep . setString ( 1 , NsConverter . streetEncode ( a . getIDVersion ( ) ) ) ; prep . setString ( 2 , NsConverter . municipalityEncode ( a . getCity ( ) . getIDVersion ( ) ) ) ; prep . setString ( 3 , a . getName ( "nl" ) ) ; prep . setString ( 4 , a . getName ( "fr" ) ) ; prep . setString ( 5 , a . getName ( "de" ) ) ; prep . setObject ( 6 , a . getStatus ( ) , Types . OTHER ) ; prep . setObject ( 7 , a . getFromDate ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . setObject ( 8 , a . getTillDate ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . setObject ( 9 , a . getBeginLife ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . setObject ( 10 , a . getEndLife ( ) , Types . TIMESTAMP_WITH_TIMEZONE ) ; prep . addBatch ( ) ; if ( ++ cnt % 10_000 == 0 ) { prep . executeBatch ( ) ; LOG . log ( Level . INFO , "Inserted {0}" , cnt ) ; } } prep . executeBatch ( ) ; }
Load streets
Load streets
// insert per 10.000 records