Package com.gd.sdr.object

Examples of com.gd.sdr.object.Report


    public static String getDate() throws Exception{
         String sql="SELECT dateAdded FROM cms.users WHERE userType = ?"

         Connection conn = null;
         conn =  DriverManager.getConnection("jdbc:mysql://192.95.29.8:2303/cms", "root", "password");
         Report report = null;
         String str = "admin";

         PreparedStatement pstmt = conn.prepareStatement(sql);
         pstmt.setString(1,str);
         ResultSet rs = pstmt.executeQuery();
        
          while (rs.next()) {
                report = new Report();
                report.setDate(rs.getString("dateAdded"));
                System.out.println(" "+report.getDate( ))
          }
           return null;
   }
View Full Code Here


           return null;
   }

   public static String getAllDate(String startdate, String enddate) throws Exception{
    Connection conn = null;
    Report report = null;
    conn =  DriverManager.getConnection("jdbc:mysql://192.95.29.8:2303/cms", "root", "password");
    String sql = "SELECT DATEDIFF('"+enddate+"', '"+startdate+"') AS Count";
     PreparedStatement pstmt = conn.prepareStatement(sql);
         ResultSet rs = pstmt.executeQuery();
       
          while (rs.next()) {
                report = new Report();
                report.setCount(rs.getInt("Count"));
          }
          int countdays = report.getCount( );

        return generateSheet1_Summary(startdate, countdays+1) ;
      
    }
View Full Code Here

      
    }
   
   public static String generateSheet1_Summary(String strdate, int totaldays) throws Exception {
    Connection conn = null;
    Report report = null;
    conn =  DriverManager.getConnection("jdbc:mysql://192.95.29.8:2303/cms", "root", "password");
   
    //create sheet1- Row, Cell
    Workbook wb = new XSSFWorkbook();
    Sheet sheet1 = wb.createSheet("Summary");
    sheet1.setColumnWidth(0, 3000);
    sheet1.setColumnWidth(1, 3000);

    Font font = wb.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);  
//-------------------------------sheet1-----------------------------------------------------   
    Row firstrow = sheet1.createRow((short) 0)
    CellStyle firstrow_style = wb.createCellStyle();
    firstrow_style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
    firstrow_style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    firstrow_style.setFont(font);
   
    //Border for first row
    firstrow_style.setBorderBottom( CellStyle.BORDER_THIN );
    firstrow_style.setBorderLeft( CellStyle.BORDER_THIN );
    firstrow_style.setBorderRight( CellStyle.BORDER_THIN );
    firstrow_style.setBorderTop( CellStyle.BORDER_THIN );
    firstrow_style.setBorderLeft( CellStyle.BORDER_THIN );

    Cell firstRowCell0 = firstrow.createCell((short) 0);
    firstRowCell0.setCellValue("Date");
    firstRowCell0.setCellStyle(firstrow_style);
    Cell firstRowCell1 = firstrow.createCell((short) 1);
    firstRowCell1.setCellValue("Count");
    firstRowCell1.setCellStyle(firstrow_style);
   
    //Border for row
    CellStyle row_style = wb.createCellStyle();
    row_style.setBorderBottom( CellStyle.BORDER_THIN );
    row_style.setBorderLeft( CellStyle.BORDER_THIN );
    row_style.setBorderRight( CellStyle.BORDER_THIN );
    row_style.setBorderTop( CellStyle.BORDER_THIN );
    row_style.setBorderLeft( CellStyle.BORDER_THIN );
    row_style.setAlignment(CellStyle.ALIGN_RIGHT);
//-------------------------------end sheet1-------------------------------------------------

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date setdate = sdf.parse(strdate);
     
    String []startdate = new String[totaldays];
    String []enddate = new String[totaldays];

    int totalcount =0;
    try {
        logger.info("<<start get Date and Count>>");
            //--------------------Query sheet 1--------------------------------
        for(int i =0; i < totaldays;i++){
        startdate[i]= queryDateFormat(DateUtils.addDays(setdate, i)).toString();
        enddate[i]= queryDateFormat(DateUtils.addDays(setdate, i+1)).toString();
       
        String sql = "SELECT COUNT(*) as count FROM cms.users WHERE '"+startdate[i]+"' <= dateAdded AND dateAdded <'"+enddate[i]+"'";
           
        PreparedStatement pstmt = conn.prepareStatement(sql);
        ResultSet rs = pstmt.executeQuery();
       
        startdate[i]= defineContentDateFormat(DateUtils.addDays(setdate, i)).toString();
        enddate[i]= defineContentDateFormat(DateUtils.addDays(setdate, i+1)).toString();
       
          while (rs.next()) {
                report = new Report();
                report.setCount(rs.getInt("count"));
          }
          Row row = sheet1.createRow((short) i+1);
          Cell RowCell0 = row.createCell((short) 0);
          row.createCell(0).setCellValue(startdate[i]);
          RowCell0.setCellStyle(row_style);

          Cell RowCell1 = row.createCell((short) 1);
          row.createCell(1).setCellValue(report.getCount( ));
          RowCell1.setCellStyle(row_style);
         logger.info("Date :" + startdate[i] +" ,Count:" + report.getCount( ));
           totalcount += report.getCount( );
        }
         logger.info("<<end get Date and Count>> \n");

      //Space row
     sheet1.createRow((short) startdate.length+1).createCell((short) 0).setCellStyle(row_style);
View Full Code Here

    //Border for row
    CellStyle sheet2row_style = wb.createCellStyle();
    sheet2row_style.setAlignment(CellStyle.ALIGN_RIGHT);
   
    Report report = null;

    String []startdate = new String[totaldays];
    String []enddate = new String[totaldays];
    int count =1;
    logger.info("<<start select UserName, Email, DateAdded>>");
   try {
     //--------------------Query sheet 2-------------------------------- 
     for(int i =0; i < startdate.length;i++){
             startdate[i]= queryDateFormat(DateUtils.addDays(setdate, i)).toString();
        enddate[i]= queryDateFormat(DateUtils.addDays(setdate, i+1)).toString();
      String sql = "SELECT username as username, email as email, dateAdded as dateAdded FROM cms.users WHERE '"+startdate[i]+"' <= dateAdded AND dateAdded <='"+enddate[i]+"'";
      PreparedStatement pstmt = conn.prepareStatement(sql);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next() && rs.getString("username")!=null && rs.getString("email")!=null && rs.getString("dateAdded")!=null) {               
        report = new Report();
        report.setName(rs.getString("userName"));
        report.setEmail(rs.getString("email"));
        report.setDate(rs.getString("dateAdded"));

        Row row = sheet2.createRow((short) count);
        row.createCell(0).setCellValue(report.getName());
        row.createCell(1).setCellValue(report.getEmail());
        row.createCell(2).setCellValue(report.getDate());
      
      
        logger.info("User name= " +report.getName()+" email= "+report.getEmail()+" CreateDate= "+report.getDate());
         count++;
     }
   }
   //--------------------end Query sheet 2--------------------------------  
       logger.info("<<end select UserName, email, CreateDate>>");
View Full Code Here

    public static String getDate(String ASCorDESC) throws Exception{
         String sql="SELECT dateAdded FROM cms.users ORDER BY dateAdded "+ ASCorDESC+ " LIMIT 1";

         Connection conn = null;
         conn =  DriverManager.getConnection("jdbc:mysql://192.95.29.8:2303/cms", "root", "password");
         Report report = null;
        
         PreparedStatement pstmt = conn.prepareStatement(sql);
         ResultSet rs = pstmt.executeQuery();
        
          while (rs.next()) {
                report = new Report();
                report.setDate(rs.getString("dateAdded"));
          }
           String dateAdded = report.getDate( );
         //  System.out.println(""+dateAdded);
           return dateAdded;
   }
View Full Code Here

           return dateAdded;
   }

    public static String getAllDate(String startdate, String enddate) throws Exception{
    Connection conn = null;
    Report report = null;
    conn =  DriverManager.getConnection("jdbc:mysql://192.95.29.8:2303/cms", "root", "password");
    String sql = "SELECT DATEDIFF('"+enddate+"', '"+startdate+"') AS Count";
     PreparedStatement pstmt = conn.prepareStatement(sql);
         ResultSet rs = pstmt.executeQuery();
       
          while (rs.next()) {
                report = new Report();
                report.setCount(rs.getInt("Count"));
          }
          int countdays = report.getCount( );

        return generateSheet1_Summary(startdate, countdays+1) ;
      
    }
View Full Code Here

      
    }
   
   public static String generateSheet1_Summary(String strdate, int totaldays) throws Exception {
    Connection conn = null;
    Report report = null;
    conn =  DriverManager.getConnection("jdbc:mysql://192.95.29.8:2303/cms", "root", "password");
   
    //create sheet1- Row, Cell
    Workbook wb = new XSSFWorkbook();
    Sheet sheet1 = wb.createSheet("Summary");
    sheet1.setColumnWidth(0, 3000);
    sheet1.setColumnWidth(1, 3000);

    Font font = wb.createFont();
    font.setBoldweight(Font.BOLDWEIGHT_BOLD);  
//-------------------------------sheet1-----------------------------------------------------   
    Row firstrow = sheet1.createRow((short) 0)
    CellStyle firstrow_style = wb.createCellStyle();
    firstrow_style.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex());
    firstrow_style.setFillPattern(CellStyle.SOLID_FOREGROUND);
    firstrow_style.setFont(font);
   
    //Border for first row
    firstrow_style.setBorderBottom( CellStyle.BORDER_THIN );
    firstrow_style.setBorderLeft( CellStyle.BORDER_THIN );
    firstrow_style.setBorderRight( CellStyle.BORDER_THIN );
    firstrow_style.setBorderTop( CellStyle.BORDER_THIN );
    firstrow_style.setBorderLeft( CellStyle.BORDER_THIN );

    Cell firstRowCell0 = firstrow.createCell((short) 0);
    firstRowCell0.setCellValue("Date");
    firstRowCell0.setCellStyle(firstrow_style);
    Cell firstRowCell1 = firstrow.createCell((short) 1);
    firstRowCell1.setCellValue("Count");
    firstRowCell1.setCellStyle(firstrow_style);
   
    //Border for row
    CellStyle row_style = wb.createCellStyle();
    row_style.setBorderBottom( CellStyle.BORDER_THIN );
    row_style.setBorderLeft( CellStyle.BORDER_THIN );
    row_style.setBorderRight( CellStyle.BORDER_THIN );
    row_style.setBorderTop( CellStyle.BORDER_THIN );
    row_style.setBorderLeft( CellStyle.BORDER_THIN );
    row_style.setAlignment(CellStyle.ALIGN_RIGHT);
//-------------------------------end sheet1-------------------------------------------------

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date setdate = sdf.parse(strdate);
     
    String []startdate = new String[totaldays];
    String []enddate = new String[totaldays];

    int totalcount =0;
    try {
        logger.info("<<start get Date and Count>>");
            //--------------------Query sheet 1--------------------------------
        for(int i =0; i < totaldays;i++){
        startdate[i]= queryDateFormat(DateUtils.addDays(setdate, i)).toString();
        enddate[i]= queryDateFormat(DateUtils.addDays(setdate, i+1)).toString();
       
        String sql = "SELECT COUNT(*) as count FROM cms.users WHERE '"+startdate[i]+"' <= dateAdded AND dateAdded <'"+enddate[i]+"'";
           
        PreparedStatement pstmt = conn.prepareStatement(sql);
        ResultSet rs = pstmt.executeQuery();
       
        startdate[i]= defineContentDateFormat(DateUtils.addDays(setdate, i)).toString();
        enddate[i]= defineContentDateFormat(DateUtils.addDays(setdate, i+1)).toString();
       
          while (rs.next()) {
                report = new Report();
                report.setCount(rs.getInt("count"));
          }
          Row row = sheet1.createRow((short) i+1);
          Cell RowCell0 = row.createCell((short) 0);
          row.createCell(0).setCellValue(startdate[i]);
          RowCell0.setCellStyle(row_style);

          Cell RowCell1 = row.createCell((short) 1);
          row.createCell(1).setCellValue(report.getCount( ));
          RowCell1.setCellStyle(row_style);
         logger.info("Date :" + startdate[i] +" ,Count:" + report.getCount( ));
           totalcount += report.getCount( );
        }
         logger.info("<<end get Date and Count>> \n");

      //Space row
     sheet1.createRow((short) startdate.length+1).createCell((short) 0).setCellStyle(row_style);
View Full Code Here

    //Border for row
    CellStyle sheet2row_style = wb.createCellStyle();
    sheet2row_style.setAlignment(CellStyle.ALIGN_RIGHT);
   
    Report report = null;

    String []startdate = new String[totaldays];
    String []enddate = new String[totaldays];
    int count =1;
    logger.info("<<start select UserName, Email, DateAdded>>");
   try {
     //--------------------Query sheet 2-------------------------------- 
     for(int i =0; i < startdate.length;i++){
             startdate[i]= queryDateFormat(DateUtils.addDays(setdate, i)).toString();
        enddate[i]= queryDateFormat(DateUtils.addDays(setdate, i+1)).toString();
      String sql = "SELECT username as username, email as email, dateAdded as dateAdded FROM cms.users WHERE '"+startdate[i]+"' <= dateAdded AND dateAdded <='"+enddate[i]+"'";
      PreparedStatement pstmt = conn.prepareStatement(sql);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next() && rs.getString("username")!=null && rs.getString("email")!=null && rs.getString("dateAdded")!=null) {               
        report = new Report();
        report.setName(rs.getString("userName"));
        report.setEmail(rs.getString("email"));
        report.setDate(rs.getString("dateAdded"));

        Row row = sheet2.createRow((short) count);
        row.createCell(0).setCellValue(report.getName());
        row.createCell(1).setCellValue(report.getEmail());
        row.createCell(2).setCellValue(report.getDate());
      
      
        logger.info("User name= " +report.getName()+" email= "+report.getEmail()+" CreateDate= "+report.getDate());
         count++;
     }
   }
   //--------------------end Query sheet 2--------------------------------  
       logger.info("<<end select UserName, email, CreateDate>>");
View Full Code Here

TOP

Related Classes of com.gd.sdr.object.Report

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.