/[projects]/dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Database.java
ViewVC logotype

Diff of /dao/FuldDaekningWorker/src/dk/daoas/fulddaekning/Database.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2200 by torben, Thu Sep 11 08:14:40 2014 UTC revision 2218 by torben, Fri Sep 12 15:23:06 2014 UTC
# Line 94  public class Database { Line 94  public class Database {
94    
95          public List<Integer> hentPostnumre() throws SQLException {          public List<Integer> hentPostnumre() throws SQLException {
96                  ArrayList<Integer> list = new ArrayList<Integer>();                  ArrayList<Integer> list = new ArrayList<Integer>();
97                    
98                    Constants consts = Constants.getInstance();
99    
100    
101                  String sql = "SELECT postnr " +                  String sql = "SELECT postnr " +
102                                           "FROM fulddaekning.adressetabel " +                                           "FROM fulddaekning.adressetabel " +
103                                           "WHERE distributor = ? and rute is not null " +                                           //"WHERE distributor = ? and rute is not null " +
104                                             "WHERE postnr BETWEEN ? AND ? " +
105                                           "GROUP BY postnr " +                                           "GROUP BY postnr " +
106                                           "ORDER by postnr";                                           "ORDER by postnr";
107                  PreparedStatement stmt = conn.prepareStatement(sql);                  PreparedStatement stmt = conn.prepareStatement(sql);
108                  stmt.setString(1, Lookup.distributor );                  //stmt.setString(1, Lookup.distributor );
109                    stmt.setInt(1, consts.getMinPostnr());
110                    stmt.setInt(2, consts.getMaxPostnr());
111                  ResultSet res = stmt.executeQuery();                  ResultSet res = stmt.executeQuery();
112    
113                  while (res.next()) {                  while (res.next()) {
# Line 117  public class Database { Line 122  public class Database {
122                  return list;                  return list;
123          }          }
124    
125          public ArrayList<Adresse> hentDaekkedeAdresser( BoundingBox bbox) throws SQLException {          public Adresse[] hentDaekkedeAdresser( BoundingBox bbox) throws SQLException {
126                  String sql = "SELECT id,postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute " +                  String sql = "SELECT id,postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute " +
127                                  "FROM fulddaekning.adressetabel " +                                  "FROM fulddaekning.adressetabel " +
128                                  "WHERE rute IS NOT NULL " +                                  "WHERE rute IS NOT NULL " +
# Line 137  public class Database { Line 142  public class Database {
142                  stmt.setDouble(4, bbox.longitudeMax);                  stmt.setDouble(4, bbox.longitudeMax);
143                  stmt.setString(5, Lookup.distributor);                  stmt.setString(5, Lookup.distributor);
144    
145                  return hentAdresseListe( stmt );                  List<Adresse> list = hentAdresseListe( stmt );
146                    return list.toArray( new Adresse[ list.size() ] );
147    
148          }          }
149    
# Line 182  public class Database { Line 188  public class Database {
188    
189    
190          protected ArrayList<Adresse> hentAdresseListe(PreparedStatement stmt) throws SQLException{          protected ArrayList<Adresse> hentAdresseListe(PreparedStatement stmt) throws SQLException{
191                  ArrayList<Adresse> list = new ArrayList<Adresse>( 30000 );                  ArrayList<Adresse> list = new ArrayList<Adresse>( 1000000 );
192    
193                  //logger.info("Starting query");                  //logger.info("Starting query");
194                  ResultSet res = stmt.executeQuery();                  ResultSet res = stmt.executeQuery();
# Line 228  public class Database { Line 234  public class Database {
234              conn = DriverManager.getConnection(              conn = DriverManager.getConnection(
235                             "jdbc:mysql://" +                             "jdbc:mysql://" +
236                             db_host +                             db_host +
237                             ":3306/",                             ":3306/?rewriteBatchedStatements=true",
238                             connectionProps);                             connectionProps);
239              logger.info("Connected to database");              logger.info("Connected to database");
240              return conn;              return conn;

Legend:
Removed from v.2200  
changed lines
  Added in v.2218

  ViewVC Help
Powered by ViewVC 1.1.20