Package database

Examples of database.MySQLConnection


    clocParsingThread.join();
  }

  public void saveResults(int idVersion) throws Exception {

    MySQLConnection conn = new MySQLConnection();
    conn.connect();

    int numLinesOfCode = this.clocParser.getNumLinesOfCode();
    int numFiles = this.clocParser.getNumFiles();
    int numComments = this.clocParser.getNumComments();
    int numPackages = this.jncssParser.getNumPackages();
    int numClasses = this.jncssParser.getNumClasses();
    int numFunctions = this.jncssParser.getNumFunctions();
    int numCodeDuplications = this.pmdParser.getNumCodeDuplications();

    conn.SQLUpdate("insert into general_stats (version , nloc , nfunc , ncl , npkg , ncom , ndupl , nfile) values ("
        + idVersion
        + ","
        + (numLinesOfCode == -1 ? "NULL" : numLinesOfCode)
        + ","
        + (numFunctions == -1 ? "NULL" : numFunctions)
        + ","
        + (numClasses == -1 ? "NULL" : numClasses)
        + ","
        + (numPackages == -1 ? "NULL" : numPackages)
        + ","
        + (numComments == -1 ? "NULL" : numComments)
        + ","
        + (numCodeDuplications == -1 ? "NULL" : numCodeDuplications)
        + "," + (numFiles == -1 ? "NULL" : numFiles) + ")");

    conn.disconnect();
  }
View Full Code Here


  public void analyzeAll() throws Exception {

    // Database connection
    System.out.println("connecting to server");
    MySQLConnection conn = new MySQLConnection();
    conn.connect();

    // Get the project repository details
    ResultSet rs = conn.SQLSelect("SELECT * FROM projects");

    while (rs.next()) {

      String url = rs.getString("repos_url");
      String user = rs.getString("repos_user");
      if (rs.wasNull())
        user = "";

      String password = rs.getString("repos_password");
      if (rs.wasNull())
        password = "";

      String name = rs.getString("name");

      int idProject = rs.getInt("id");
      int lastVersion = 1;
      ResultSet rs2 = conn
          .SQLSelect("select max(version)+1 as last_version from versions where project = "
              + idProject);

      while (rs2.next()) {
        lastVersion = Math.max(lastVersion, rs2.getInt("last_version"));
      }

      int idVersion = 1;
      conn.SQLUpdate("insert into versions (project , version , creation_date) values ("
          + idProject + "," + lastVersion + " , sysdate())");

      ResultSet rs3 = conn
          .SQLSelect("select id from versions where version = "
              + lastVersion + " and project = " + idProject);

      while (rs3.next()) {
        idVersion = rs3.getInt("id");
      }

      System.out.println("Checking out project : " + name + " ...");

      checkoutProject(url, user, password, CHECKOUT_DESTINATION_PATH
          + "/" + name);

      deleteDirectory(new File(REPORTS_PATH));

      File reportsDir = new File(REPORTS_PATH);

      if (reportsDir.mkdir()) {
        System.out.println("Reports directory created");
      }

      ExecuteScript javaNcssThread = new ExecuteScript(JNCSS_SCRIPT_PATH,
          CHECKOUT_DESTINATION_PATH + "/" + name + "/src");

      ExecuteScript pmdThread = new ExecuteScript(PMD_SCRIPT_PATH,
          CHECKOUT_DESTINATION_PATH + "/" + name + "/src");

      ExecuteScript clocThread = new ExecuteScript(CLOC_SCRIPT_PATH,
          CHECKOUT_DESTINATION_PATH + "/" + name + "/src");

      ExecuteScript findBugsThread = new ExecuteScript(
          FINDBUGS_SCRIPT_PATH, CHECKOUT_DESTINATION_PATH + "/"
              + name + "/bin");

      ExecuteScript coberturaThread = new ExecuteScript(
          COBERTURA_SCRIPT_PATH, CHECKOUT_DESTINATION_PATH + "/"
              + name + "/bin");

      System.out.println("Analyzing ...");

      System.out.println("Starting JavaNCSS ...");
      javaNcssThread.start();
      System.out.println("Starting PMD /CPD ...");
      pmdThread.start();
      System.out.println("Starting CLOC ...");
      clocThread.start();
      System.out.println("Starting FindBugs ...");
      findBugsThread.start();

      javaNcssThread.join();
      pmdThread.join();
      clocThread.join();
      findBugsThread.join();
      System.out.println("JavaNCSS ended");
      System.out.println("PMD /CPD ended");
      System.out.println("CLOC ended");
      System.out.println("FindBugs ended");

      System.out.println("Starting Cobertura ...");
      coberturaThread.start();
      coberturaThread.join();
      System.out.println("Cobertura ended");

      System.out.println("Analyzing done");

      GeneralParserThread generalParser = new GeneralParserThread(
          XML_FILE_PATH + "/" + JNCSS_XML_FILE, XML_FILE_PATH + "/"
              + PMD_XML_FILE,
          XML_FILE_PATH + "/" + CLOC_XML_FILE, CLOC_LANGUAGE,
          idVersion);

      CoberturaParserThread coberturaParserThread = new CoberturaParserThread(
          XML_FILE_PATH + "/" + this.COBERTURA_XML_FILE, idVersion);

      FindbugsParserThread findBugsParserThread = new FindbugsParserThread(
          XML_FILE_PATH + "/" + this.FINDBUGS_XML_FILE, idVersion);

      System.out.println("Parsing reports ...");

      generalParser.start();
      coberturaParserThread.start();
      findBugsParserThread.start();

      generalParser.join();
      coberturaParserThread.join();
      findBugsParserThread.join();

      System.out.println("Parsing of the reports done");

      System.out.println("Deleting directories ...");

      File path = new File(CHECKOUT_DESTINATION_PATH);
      deleteDirectory(path);
      path = new File(XML_FILE_PATH);
      deleteDirectory(path);

      System.out.println("Directories deleted");
    }

    conn.disconnect();
  }
View Full Code Here

  }

  @Override
  public void saveResults(int idVersion) throws Exception {

    MySQLConnection conn = new MySQLConnection();
    conn.connect();

    conn.SQLUpdate("insert into test_stats (version , ncovl) values ("
        + idVersion + " , " + (numLines.equals("") ? "NULL" : numLines)
        + ")");

    conn.disconnect();
  }
View Full Code Here

  }

  public void saveResults(int idVersion) throws Exception {

    MySQLConnection conn = new MySQLConnection();
    conn.connect();
    Iterator<InsertList> i = insertList.iterator();
    while (i.hasNext()) {
      InsertList e = i.next();

      // Mandatory info on the error has been successfully retrieved
      if (!e.abbrev.isEmpty() && !e.category.isEmpty()
          && !e.type.isEmpty()) {

        conn.SQLUpdate("insert into findbugs_stats (version , category , abbrev , type , file , line) values ("
            + idVersion
            + ",'"
            + e.category
            + "',"
            + "'"
            + e.abbrev
            + "',"
            + "'"
            + e.type
            + "',"
            + (e.file.equals("") ? "NULL," : "'" + e.file + "',")
            + (e.line.equals("") ? "NULL" : e.line) + ")");
      }
      // Couldn't retrieve enough info on the error
      else {

        System.err
            .println("Findbugs error skipped because of lack of info");
      }
    }

    conn.disconnect();
  }
View Full Code Here

TOP

Related Classes of database.MySQLConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.