Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ListOfCheckins readFromDB(double CoreMinY, double CoreMaxY) {
- //checkins = new HashMap<String, Integer>();
- ListOfCheckins checkins = new ListOfCheckins();
- Connection con = null;
- java.sql.PreparedStatement pst = null;
- ResultSet rs = null;
- String url = "jdbc:mysql://83.212.117.76:3306/ds_systems_2016?autoReconnect=true&useSSL=false";
- String user = "omada8";
- String password = "omada8db";
- try {
- con = DriverManager.getConnection(url, user, password);
- pst = con.prepareStatement("select POI, POI_name, POI_category, POI_category_id, latitude, longitude, time, photos"
- +" from checkins where (latitude between " + CoreMinY + " and " + CoreMaxY
- + ") " + "and (longitude between " + minX + " and " + maxX + ") " + "and time between \'" + minDatetime +"\' and \'"+ maxDatetime +"\';");
- rs = pst.executeQuery();
- String POI, POI_name, POI_category, POI_category_id, time, photos;
- double latitude, longitude;
- while (rs.next()) {
- POI = rs.getString(1);
- POI_name = rs.getString(2);
- POI_category = rs.getString(3);
- POI_category_id = rs.getString(4);
- latitude = rs.getDouble(5);
- longitude = rs.getDouble(6);
- time = rs.getString(7);
- photos = rs.getString(8);
- checkins.addCheckin(POI, POI_name, POI_category, POI_category_id, longitude, latitude, time, photos);
- }
- } catch (SQLException ex) {
- Logger lgr = Logger.getLogger(Mapper.class.getName());
- lgr.log(Level.SEVERE, ex.getMessage(), ex);
- } finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (pst != null) {
- pst.close();
- }
- if (con != null) {
- con.close();
- }
- } catch (SQLException ex) {
- Logger lgr = Logger.getLogger(Mapper.class.getName());
- lgr.log(Level.WARNING, ex.getMessage(), ex);
- }
- }
- return checkins;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement