예제 #1
0
파일: SetPW.java 프로젝트: WongTai/snippets
  public static void main(String args[]) {
    try {
      BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
      PhotoConfig config = new PhotoConfig();
      PhotoSecurity security = new PhotoSecurity();

      String user = null;
      if (args.length < 1) {
        System.out.print("Enter username:  "******"Enter password:  "******"New password is " + newpw);

      Class.forName(config.get("dbDriverName"));
      Connection db =
          DriverManager.getConnection(
              config.get("dbSource"), config.get("dbUser"), config.get("dbPass"));
      String query =
          "update wwwusers set password='******'\n" + "\twhere username='******'";
      Statement st = db.createStatement();
      st.executeUpdate(query);
    } catch (Exception e) {
      System.out.println(e);
      e.printStackTrace();
    }
  }
예제 #2
0
 public void run() {
   // Do a flush at the beginning, just in case stuff has been
   // building up.
   try {
     doFlush();
   } catch (Exception e1) {
     // Don't care, all these can fail, we'll just keep trying.
   }
   for (; ; ) {
     try {
       PhotoConfig p = new PhotoConfig();
       int m = Integer.valueOf(p.get("storer_sleep")).intValue();
       // Check every x minutes
       sleep(m * 60 * 1000);
     } catch (Exception e) {
     } finally {
       doFlush();
     }
   }
 }