package org.hwo.pulscounter.application; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.LinkedList; import java.util.List; import org.hwo.pulscounter.elements.WorkShift; public class InspectorApplication { List workShifts; Connection db; public InspectorApplication(){ workShifts = new LinkedList(); /* workShifts.add(new WorkShift()); workShifts.add(new WorkShift()); workShifts.get(0).setName("Frühschicht"); workShifts.get(0).getBegins().setHours(6); workShifts.get(0).getBegins().setMinutes(0); workShifts.get(0).getEnds().setHours(15); workShifts.get(0).getEnds().setMinutes(0); workShifts.get(1).setName("Frühschicht"); workShifts.get(1).getBegins().setHours(15); workShifts.get(1).getBegins().setMinutes(0); workShifts.get(1).getEnds().setHours(3); workShifts.get(1).getEnds().setMinutes(0); */ connect(); try { Statement stat = db.createStatement(); ResultSet result = stat.executeQuery("SELECT * from workshifts"); while (result.next()){ WorkShift shift = new WorkShift(); shift.setName(result.getString("name")); shift.getBegins().setTime( result.getTime("begins")); shift.getEnds().setTime( result.getTime("ends")); workShifts.add(shift); } result.close(); stat.close(); } catch (Exception e) { e.printStackTrace(); } } public void connect(){ try { Class.forName("org.postgresql.Driver"); db = DriverManager.getConnection("jdbc:postgresql://10.112.1.1/pulscounter", "haraldwolff","diekleinefeine"); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } } public WorkShift[] getWorkShifts(){ return workShifts.toArray(new WorkShift[0]); } public Connection getConnection() { return db; } } /*** properties.put("hibernate.connection.driver", "org.postgresql.Driver"); properties.put("hibernate.connection.url", ); ***/