/[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 2152 by torben, Wed May 7 08:10:45 2014 UTC revision 2192 by torben, Thu Jun 19 10:24:16 2014 UTC
# Line 21  public class Database { Line 21  public class Database {
21          Connection conn;          Connection conn;
22          PreparedStatement saveStmt;          PreparedStatement saveStmt;
23    
24          public Database(Properties conf)  throws SQLException,IOException {          public Database(SafeProperties conf)  throws SQLException,IOException {
25                  this.conn = getConnection( conf );                        this.conn = getConnection( conf );      
26    
27                  String sql = "INSERT INTO fulddaekning.afstand_anden_rute_thn (orgId,orgPostnr, orgAdresse,orgGadeid,orgHusnr,orgHusnrBogstav,orgLatitude,orgLongitude,orgRute,id,postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute,afstand,`timestamp`) "+                  String sql = "INSERT INTO fulddaekning.afstand_anden_rute_ny (orgId,orgPostnr, orgAdresse,orgGadeid,orgHusnr,orgHusnrBogstav,orgLatitude,orgLongitude,orgRute,id,postnr,adresse,gadeid,husnr,husnrbogstav,latitude,longitude,rute,afstand,`timestamp`) "+
28                                  "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, now() )";                                  "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, now() )";
29    
30                  saveStmt = conn.prepareStatement(sql);                            saveStmt = conn.prepareStatement(sql);          
# Line 32  public class Database { Line 32  public class Database {
32          }          }
33    
34          public void resetResultTable() throws SQLException {          public void resetResultTable() throws SQLException {
35                  logger.info("Truncating result table");                  logger.info("Dropping old result table (if exists)");
36                  String sql = "TRUNCATE TABLE fulddaekning.afstand_anden_rute_thn";                  String sql = "DROP TABLE IF EXISTS fulddaekning.afstand_anden_rute_ny";
37                  conn.createStatement().executeUpdate(sql);                  conn.createStatement().executeUpdate(sql);
38                    
39                    logger.info("Create new result table");
40                    sql = "CREATE TABLE fulddaekning.afstand_anden_rute_ny LIKE fulddaekning.afstand_anden_rute";
41                    conn.createStatement().executeUpdate(sql);              
42            }      
43            
44            public void renameResultTables() throws SQLException {
45                    logger.info("Dropping old backup table (if exists)");
46                    String sql = "DROP TABLE IF EXISTS fulddaekning.afstand_anden_rute_old";
47                    conn.createStatement().executeUpdate(sql);
48                    
49                    logger.info("Rename tables");
50                    sql = "RENAME TABLE fulddaekning.afstand_anden_rute TO fulddaekning.afstand_anden_rute_old, fulddaekning.afstand_anden_rute_ny TO fulddaekning.afstand_anden_rute";
51                    conn.createStatement().executeUpdate(sql);              
52          }                }      
53    
54          public BoundingBox getBoundingbox(int postnr) throws SQLException {          public BoundingBox getBoundingbox(int postnr) throws SQLException {
# Line 190  public class Database { Line 203  public class Database {
203                  return list;                  return list;
204          }          }
205    
206          public Connection getConnection(Properties conf) throws SQLException, IOException {          public Connection getConnection(SafeProperties conf) throws SQLException, IOException {
207                                    
208                  String db_host = conf.getProperty("DB_HOST");                  String db_host = conf.getSafeProperty("DB_HOST");
209                  String db_user = conf.getProperty("DB_USER");                  String db_user = conf.getSafeProperty("DB_USER");
210                  String db_pass = conf.getProperty("DB_PASS");                  String db_pass = conf.getSafeProperty("DB_PASS");
211    
212                                    
213                                    

Legend:
Removed from v.2152  
changed lines
  Added in v.2192

  ViewVC Help
Powered by ViewVC 1.1.20