public static void main(String[] args) {

    hadoop_Training3_CATCH demo = new hadoop_Training3_CATCH();
    demo.conn = demo.initdb(demo.db_name);

    if (demo.conn == null) {
      System.out.println(" Databasse connection is null");
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      try {
        br.readLine();
      } catch (Exception e) {
      }
    }

    // create new file for every run
    try {
      BufferedWriter bw = new BufferedWriter(new FileWriter(demo.logged_file_path));
      bw.close();
      bw = new BufferedWriter(new FileWriter(demo.non_logged_file_path));
      bw.close();

    } catch (IOException e1) {

      e1.printStackTrace();
    }

    try {
      BufferedReader br = new BufferedReader(new FileReader(demo.listing_file_path));
      String file_name = br.readLine();
      while (br != null) {
        System.out.println("Parsing File=" + file_name);
        int len = (file_name.split("\\\\")).length;
        demo.package_name = file_name.split("\\\\")[len - 2];
        demo.temp_file_path = file_name.replace("\\", "\\\\");
        // demo.id = 0;
        demo.ast_prser(file_name);
        file_name = br.readLine();
        // br=null;
      }
    } catch (FileNotFoundException e) {
      System.out.println("Error.. Can not open the listing file");
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public void write_in_file(
      String if_block, String if_expr, String if_train_con, String method_content, int log_count) {
    BufferedWriter bw = null;
    int logged = 0;

    if (log_count != 0) {
      logged = 1;
    }

    if (logged == 1) {

      try {
        bw = new BufferedWriter(new FileWriter(logged_file_path, true));

      } catch (IOException e) {

        e.printStackTrace();
      }
    } else {
      try {
        bw = new BufferedWriter(new FileWriter(non_logged_file_path, true));

      } catch (IOException e) {
        e.printStackTrace();
      }
    } // else

    try {
      bw.write("File Path=" + temp_file_path + "\n");
      bw.write("Package Name =" + package_name + "\n");
      bw.write("class name=" + class_name + "\n");
      bw.write("Method Name=" + method_name + "\n");
      bw.write("If Content=" + if_train_con + "\n");
      // bw.write("All Catch Blocks="+ all_catch_as_string+"\n");
      // bw.write("method parameter = "+ method_parameter +"\n");
      bw.write("method content=" + method_content + "\n");
      bw.write("--------------------\n");
      bw.close();
    } catch (IOException e) {

      e.printStackTrace();
    }
  }
  public void write_in_file(
      String catch_block,
      String expr_type,
      String try_con,
      String all_catch_as_string,
      String method_content,
      int log_count,
      String method_parameter) {
    // log_count=1;
    // id++;
    BufferedWriter bw = null;
    int logged = 0;

    if (log_count != 0) {
      logged = 1;
    }

    if (logged == 1) {

      try {
        bw = new BufferedWriter(new FileWriter(logged_file_path, true));

      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    } else {
      try {
        bw = new BufferedWriter(new FileWriter(non_logged_file_path, true));

      } catch (IOException e) {
        e.printStackTrace();
      }
    } // else

    /* String insert_str= "insert into "+table+" values(\""+package_name+"\",\""+class_name+"\",\""+method_name+"\","+  id+",\""+method_content+"\",\""+
    log_levels_combined+"\",\""+temp_file_path+"\","+"\""+if_block+"\",\""+expr_type+"\","+log_count+",\""
    +if_train_con+"\","+logged+")";
    System.out.println("Insert str"+insert_str);
    */

    try {
      bw.write("File Path=" + temp_file_path + "\n");
      bw.write("Package Name =" + package_name + "\n");
      bw.write("class name=" + class_name + "\n");
      bw.write("Method Name=" + method_name + "\n");
      bw.write("Try Content=" + try_con + "\n");
      bw.write(" All Catch Blocks=" + all_catch_as_string + "\n");
      bw.write("method parameter = " + method_parameter + "\n");
      bw.write("method content=" + method_content + "\n");
      bw.write("--------------------\n");
      bw.close();
    } catch (IOException e) {

      e.printStackTrace();
    }
  }