コード例 #1
0
ファイル: JdbcProxyGenerator.java プロジェクト: Colin25/c3p0
 static void genclass(DelegatorGenerator dg, Class intfcl, String fqcn, File srcroot)
     throws IOException {
   File genDir = new File(srcroot, dirForFqcn(fqcn));
   if (!genDir.exists()) {
     System.err.println(
         JdbcProxyGenerator.class.getName()
             + " -- creating directory: "
             + genDir.getAbsolutePath());
     genDir.mkdirs();
   }
   String fileName = CodegenUtils.fqcnLastElement(fqcn) + ".java";
   Writer w = null;
   try {
     w = new BufferedWriter(new FileWriter(new File(genDir, fileName)));
     dg.writeDelegator(intfcl, fqcn, w);
     w.flush();
     System.err.println("Generated " + fileName);
   } finally {
     try {
       if (w != null) w.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
コード例 #2
0
ファイル: FileUtil.java プロジェクト: zh69183787/wd-stptm
  /**
   * �õ�ϵͳ���õ��ϴ��ļ�����·��
   *
   * @return String
   */
  public static String getPath(String loadPath) {
    String path = PropertiesReader.GetProptery(loadPath);
    if (path == null || "".equals(path)) {
      throw new java.lang.IllegalStateException("�ϴ��ļ��ı���·��û�����á�" + loadPath + "=?");
    }

    File file = new File(path);
    if (!file.isDirectory()) {
      file.mkdirs();
    }
    return path;
  }
コード例 #3
0
ファイル: FileUtil.java プロジェクト: zh69183787/wd-stptm
 /*
  * �������µ��ļ�·���ַ�
  */
 private static String getAbstractPath(String path) {
   Calendar cl = Calendar.getInstance();
   int year = cl.get(Calendar.YEAR);
   int month = cl.get(Calendar.MONTH);
   StringBuffer buffer = new StringBuffer();
   buffer.append(year);
   buffer.append("/");
   month++;
   if (month < 10) {
     buffer.append(0);
   }
   buffer.append(month);
   buffer.append("/");
   File renameTo = new File(path + buffer.toString());
   if (!renameTo.isDirectory()) {
     renameTo.mkdirs();
   }
   return buffer.toString();
 }
コード例 #4
0
ファイル: LoadData.java プロジェクト: andl/benchmarkSQL
  private static void writeResultToResultsFile(
      String logFileLocation,
      String executingDatabaseName,
      long runTime,
      long rowsLoaded,
      long rowsLoadedPerSecond) {
    String resultsFolderPath =
        logFileLocation + "benchmark-results" + File.separator + "load-data-summary";

    // Create folder if it doesn't exist.
    File resultsFolder = new File(resultsFolderPath);
    resultsFolder.mkdirs();

    // Add results to a CSV file for a single database, and to a generic file for all database
    // results.
    File specificDbResultsFile =
        new File(resultsFolderPath + File.separator + executingDatabaseName + ".csv");
    addToResultsFile(
        executingDatabaseName, runTime, rowsLoaded, rowsLoadedPerSecond, specificDbResultsFile);

    File genericResultsFile = new File(resultsFolderPath + File.separator + "all.csv");
    addToResultsFile(
        executingDatabaseName, runTime, rowsLoaded, rowsLoadedPerSecond, genericResultsFile);
  }
コード例 #5
0
  /**
   * Perrform process.
   *
   * @return Message that would be set to process infor summary (no use currently)
   * @throws Exception if not successful
   */
  protected String doIt() throws Exception {
    // 	load query into cache file directly
    // int userId= this.getAD_User_ID();
    // User user= SecurityUtils.getUser(userId);

    Connection conn = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;
    QueryEngine engine = QueryEngine.getInstance();
    conn = engine.getConnection();

    Configurations conf =
        (Configurations)
            WebUtils.getServletContextManager().getActor(nds.util.WebKeys.CONFIGURATIONS);
    String folder = conf.getProperty("ahyy.payment.folder.download", "e:/act/ahyy/download");
    File fd = new File(folder);
    if (!fd.exists()) fd.mkdirs();
    ahyyCode = conf.getProperty("ahyy.payment.code");
    if (ahyyCode == null || ahyyCode.length() != 8)
      throw new NDSException("Wrong code for bank payment interface");

    SimpleDateFormat df = new SimpleDateFormat("yyMMdd");
    String ftpFile = "MPAYREP" + ahyyCode + df.format(new java.util.Date());
    String file = folder + "/" + ftpFile;
    StringBuffer sb = new StringBuffer();
    String lineSep = Tools.LINE_SEPARATOR;
    try {
      // 下载文件
      CommandExecuter cmd = new CommandExecuter(folder + "/log/" + ftpFile + ".log");
      String exec = conf.getProperty("ahyy.payment.download", "e:/act/bin/download.cmd");
      int err = cmd.run(exec + " " + ftpFile);
      if (err != 0) {
        throw new NDSException("Error(code=" + err + ") when doing " + exec + " " + ftpFile);
      }
      if (!(new File(file)).exists()) {
        throw new NDSException("File not downloaded when doing " + exec + " " + ftpFile);
      }
      BufferedReader in = new BufferedReader(new FileReader(file));
      in.readLine(); // skip first line, which is summary
      String line = in.readLine();
      pstmt =
          conn.prepareStatement(
              "update b_pay_sum set state=?, err_code =? where billno=? and state='R'");
      while (line != null) {
        log.debug(line);
        if (line.length() < 34) {
          log.debug("line not has length: 34");
        }

        /*
        String billType= line.substring(0,2);
        String billNo= line.substring(0, 22);// billno
        String amt=line.substring(22,34);
        String ack=line.substring(34,36);*/
        String billNo = line.substring(0, 20); // billno
        String amt = line.substring(20, 32);
        String ack = line.substring(32, 34);
        if ("00".equals(ack)) {
          java.math.BigDecimal bd = new java.math.BigDecimal(amt);
          pstmt.setString(1, "Y");
          pstmt.setNull(2, java.sql.Types.VARCHAR);
          pstmt.setString(3, billNo);
          int ret = pstmt.executeUpdate();
          if (ret != 1) {
            sb.append(line + "(updated " + ret + " lines)").append(lineSep);
          }
        } else {
          pstmt.setString(1, "P");
          pstmt.setString(2, ack);
          pstmt.setString(3, billNo);
          int ret = pstmt.executeUpdate();
          if (ret != 1) {
            sb.append(line + "(updated " + ret + " lines)").append(lineSep);
          }
        }
        line = in.readLine();
      }
      in.close();
      try {
        log.debug("Move " + file + " to " + folder + "/log/" + ftpFile);
        (new File(file)).renameTo(new File(folder + "/log/" + ftpFile));
      } catch (Throwable t) {
        log.error("Fail to move " + file + " to " + folder + "/log/" + ftpFile, t);
      }
      Vector vet = new Vector();
      String log = sb.toString();
      this.log.debug(log);
      this.addLog(log);
      return "完成";
    } finally {
      if (rs != null)
        try {
          rs.close();
        } catch (Throwable t) {
        }
      if (pstmt != null)
        try {
          pstmt.close();
        } catch (Throwable t) {
        }
      if (conn != null)
        try {
          conn.close();
        } catch (Throwable t) {
        }
    }
  }