view flys-aft/src/main/java/de/intevation/aft/Sync.java @ 4076:039413d7e394

Load gauges from both dbs. flys-aft/trunk@3436 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 16 Dec 2011 11:26:12 +0000
parents dbd0b3b1b8b8
children 97de7a552b79
line wrap: on
line source
package de.intevation.aft;

import java.io.File;

import java.sql.SQLException;

import org.w3c.dom.Document;

import de.intevation.utils.XML;

import de.intevation.db.ConnectionBuilder;
import de.intevation.db.ConnectedStatements;

public class Sync
{
    public static final String FLYS = "flys";
    public static final String AFT  = "aft";

    public static final String CONFIG_FILE =
        System.getProperty("config.file", "config.xml");

    public static void main(String [] args) {

        File configFile = new File(CONFIG_FILE);

        if (!configFile.isFile() || !configFile.canRead()) {
            System.err.println("cannot read config file");
            System.exit(1);
        }

        Document config = XML.parseDocument(configFile, Boolean.FALSE);

        if (config == null) {
            System.err.println("cannot load config");
            System.exit(1);
        }

        ConnectionBuilder aftConnectionBuilder =
            new ConnectionBuilder(AFT, config);

        ConnectionBuilder flysConnectionBuilder =
            new ConnectionBuilder(FLYS, config);

        ConnectedStatements aftStatements  = null;
        ConnectedStatements flysStatements = null;
        try {
            aftStatements  = aftConnectionBuilder.getConnectedStatements();
            flysStatements = flysConnectionBuilder.getConnectedStatements();
            Rivers rivers = new Rivers();
            rivers.sync(aftStatements, flysStatements);
        }
        catch (SQLException sqle) {
            sqle.printStackTrace();
            System.err.println("syncing failed: " + sqle.getMessage());
        }
        finally {
            if (aftStatements != null) {
                aftStatements.close();
            }
            if (flysStatements != null) {
                flysStatements.close();
            }
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org