Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Connection connection = null;
- String sql = "insert into rideoffers (creationdate, releasedate, numberofseats, vehicletype, baggagetype, ridecycle, backoutinterval, description, firststation) values (timestamp '2014-11-26 08:00', timestamp '2014-11-28 08:00', 4, 'CAR', 'MEDIUM', 'SINGLE', 1, 'Dies ist eine Testfahrt.', 1)";
- try {
- connection = ConnectionPool.getInstance().getConnection();
- Statement statement = connection.createStatement();
- statement.executeQuery(sql);
- sql = "insert into stations (id, location, district, nextstation, starttime) VALUES (3, 'Passau', 'ZOB', NULL, timestamp '2014-11-28 20:00');";
- statement.executeQuery(sql);
- sql = "insert into stations (id, location, district, nextstation, starttime) VALUES (2, 'München', 'München Hbf', 3, 2014-11-28 22:00');";
- statement.executeQuery(sql);
- sql = "insert into stations (id, location, district, nextstation, starttime) VALUES (1, 'Rosenheim', 'Erlenau', 2, 2014-11-28 23:00');";
- statement.executeQuery(sql);
- } catch (SQLException e) {
- System.out.println("insert funktioniert ned");
- }
- search = new Search();
- search.setStart("München");
- search.setDestination("Erlenau");
- LocalDateTime date = LocalDateTime.of(LocalDate.of(2014, 11, 28),
- LocalTime.MIDNIGHT);
- search.setDate(Utility.convertFromLocalDateTime(date));
- try {
- int offerCount = RideOfferDAO.getOfferCount(search, null);
- System.out.println("OfferCount: " + offerCount);
- } catch (StorageException e) {
- System.out.println("storageException");
- }
- //Utitlity Klasse
- public static Date convertFromLocalDateTime(LocalDateTime date) {
- Calendar calendar = Calendar.getInstance();
- calendar.set(date.getYear(), date.getMonthValue(), date.getDayOfMonth());
- return new java.util.Date(calendar.getTimeInMillis());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement