// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package routing.demo.client;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class Setup {
    private static void doFile(String fnm) throws IOException {
        try(OutputStream os = new FileOutputStream(fnm)) {
            // nothing
        }
    }
    public static void doDB() throws SQLException {
        try(Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Test", "root", "")) {
            Statement stmt = con.createStatement();
            try {
                stmt.executeUpdate("DROP TABLE data");
            } catch (SQLException e) {
                // OK
            }
            stmt.executeUpdate("CREATE TABLE data (id INTEGER AUTO_INCREMENT, channel VARCHAR(10), ival INTEGER, sval VARCHAR(100), PRIMARY KEY(id))");
        }
    }
    public static void main(String[] args) throws Exception {
        doDB();
        doFile("/work/camel/out/socket.log");
        doFile("/work/camel/out/file.log");
        doFile("/work/camel/out/mq.log");
        doFile("/work/camel/out/http.log");
        doFile("/work/camel/out/router.log");
        doFile("/work/svc.log");
    }
}
