⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manager.java

📁 A brew application taking backup of the device
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package MyPackage;import DBConnection.*;import java.sql.*;import javax.servlet.http.HttpSession;/** * * @author @n@ */public class Manager {       DBConnection dbc = null;       ResultSet rs = null;       HttpSession ssMgr = null;              public Manager () {              dbc = new DBConnection ();       }              public String insertValue(String user, String FName, String LName, String PhNo, java.util.Date date) throws SQLException {              java.sql.Date mydate = new java.sql.Date(date.getTime());              int count=0;              String backDate=null;              String query="select Distinct back_date from back_up";              rs=dbc.select(query);              try{                  while(rs.next()){                      count++;                  }              }catch(SQLException ex){                  ex.printStackTrace();              }              if(count>3){                  String query1="select min(back_date)  as back from back_up where back_up.user_id='"+user+"'";                  rs=dbc.select(query1);                  try{                      while(rs.next()){                          backDate=rs.getString("back");                      }                  }catch(SQLException ex){                      ex.printStackTrace();                  }                 String query2= "delete from back_up where back_up.back_date='"+backDate+"' AND back_up.user_id='"+user+"'";                 dbc.delete(query2);                 String query3= "delete from back_date where date='"+backDate+"' AND back_date.user_id='"+user+"'";                 dbc.delete(query3);              }              String Query = "Insert into back_up values('"+user+"','"+FName+"','"+LName+"','"+PhNo+"','"+mydate+"')";              dbc.insert(Query);                                    return "SUCCESS";       }       public String insertInBackDate(String user, java.util.Date date) throws SQLException {              java.sql.Date mydate = new java.sql.Date(date.getTime());              String Query = "Insert into back_date values('"+user+"','"+mydate+"')";              dbc.insert(Query);                         return "SUCCESS";       }       public String insertValue1(String user, String FName, String LName, String PhNo, java.util.Date date) throws SQLException {              java.sql.Date mydate = new java.sql.Date(date.getTime());              String Query = "Insert into temp values('"+user+"','"+FName+"','"+LName+"','"+PhNo+"','"+mydate+"')";              dbc.insert(Query);                          return "successfully saved in table temp ";       }              public ReturnType selectValue (String userId, String dt) {                            ReturnType rt = new ReturnType();              int counter = 0;              boolean bool = false;              String returnedString = null;              String[] temp;              String tempDt;              temp = dt.split("-");              String mm = temp[1];                            String mon=null;              if (mm.equalsIgnoreCase("Jan")) mon = "01";              if (mm.equalsIgnoreCase("Feb")) mon = "02";              if (mm.equalsIgnoreCase("Mar")) mon = "03";              if (mm.equalsIgnoreCase("Apr")) mon = "04";              if (mm.equalsIgnoreCase("May")) mon = "05";              if (mm.equalsIgnoreCase("Jun")) mon = "06";              if (mm.equalsIgnoreCase("Jul")) mon = "07";              if (mm.equalsIgnoreCase("Aug")) mon = "08";              if (mm.equalsIgnoreCase("Sep")) mon = "09";              if (mm.equalsIgnoreCase("Oct")) mon = "10";              if (mm.equalsIgnoreCase("Nov")) mon = "11";              if (mm.equalsIgnoreCase("Dec")) mon = "12";              tempDt = temp[2]+"-"+mon+"-"+temp[0];              try {                                   String Query = "SELECT back_up.fname, back_up.lname, back_up.contact_no, back_up.back_date FROM back_up Inner Join user_master ON user_master.user_id = back_up.user_id WHERE back_up.user_id ='"+userId+"'AND user_master.create_date =  '"+tempDt+"' ";                  rs = dbc.select(Query);                  while( rs.next() ) {                        String firstName = rs.getString("back_up.fname");                        String lastName = rs.getString("back_up.lname");                        String phone = rs.getString("back_up.contact_no");                        String date = rs.getString("back_up.back_date");                        String[] temp1;                        temp1 = date.split("-");                        String month = temp1[1];                        if(month.equals("01")) month = "Jan";                        if(month.equals("02")) month = "Feb";                        if(month.equals("03")) month = "Mar";                        if(month.equals("04")) month = "Apr";                        if(month.equals("05")) month = "May";                        if(month.equals("06")) month = "Jun";                        if(month.equals("07")) month = "Jul";                        if(month.equals("08")) month = "Aug";                        if(month.equals("09")) month = "Sep";                        if(month.equals("10")) month = "Oct";                        if(month.equals("11")) month = "Nov";                        if(month.equals("12")) month = "Dec";                        String tempDate = temp[0] + "-" + month + "-" + temp[2];                                               returnedString = firstName+":"+lastName+":"+phone+":"+tempDate;                        counter ++;                        if (!bool){                            bool=true;                            rt.intType =counter;                            rt.stringType = returnedString;                        }                        else{                            rt.stringType = rt.stringType +","+returnedString;                            rt.intType = counter;                        }                                                               }              } catch (Exception e) { }                           return rt;       }       //**************************************************************************//        public ReturnType selectValue1 (String userId, String dt) {                            ReturnType rt = new ReturnType();              int counter = 0;              boolean bool = false;              String returnedString = "";              String[] temp;              String tempDt;              temp = dt.split("-");              String mm = temp[1];              String mon=null;              if (mm.equalsIgnoreCase("Jan")) mon = "01";              if (mm.equalsIgnoreCase("Feb")) mon = "02";              if (mm.equalsIgnoreCase("Mar")) mon = "03";              if (mm.equalsIgnoreCase("Apr")) mon = "04";              if (mm.equalsIgnoreCase("May")) mon = "05";              if (mm.equalsIgnoreCase("Jun")) mon = "06";              if (mm.equalsIgnoreCase("Jul")) mon = "07";              if (mm.equalsIgnoreCase("Aug")) mon = "08";              if (mm.equalsIgnoreCase("Sep")) mon = "09";              if (mm.equalsIgnoreCase("Oct")) mon = "10";              if (mm.equalsIgnoreCase("Nov")) mon = "11";              if (mm.equalsIgnoreCase("Dec")) mon = "12";              tempDt = temp[2]+"-"+mon+"-"+temp[0];              try {                                   String Query1 = "SELECT back_up.fname as Fname, back_up.lname as Lname, back_up.contact_no as ContactNo, back_up.back_date as BackDate FROM back_up where back_up.user_id ='"+userId+"' AND back_up.back_date ='"+tempDt+"' AND back_up.contact_no NOT IN ( SELECT temp.contact_no FROM temp )";                                      rs = dbc.select(Query1);                  while( rs.next() ) {                        String firstName = rs.getString("Fname");                        String lastName = rs.getString("Lname");                        String phone = rs.getString("ContactNo");                        String date = rs.getString("BackDate");                        String[] temp1;                        temp1 = date.split("-");                        String month = temp1[1];                        if(month.equals("01")) month = "Jan";                        if(month.equals("02")) month = "Feb";                        if(month.equals("03")) month = "Mar";                        if(month.equals("04")) month = "Apr";                        if(month.equals("05")) month = "May";                        if(month.equals("06")) month = "Jun";                        if(month.equals("07")) month = "Jul";                        if(month.equals("08")) month = "Aug";                        if(month.equals("09")) month = "Sep";                        if(month.equals("10")) month = "Oct";                        if(month.equals("11")) month = "Nov";                        if(month.equals("12")) month = "Dec";                        String tempDate = temp[0] + "-" + month + "-" + temp[2];                        returnedString = firstName+":"+lastName+":"+phone+":"+tempDate;                        counter ++;                        if (!bool){                            bool=true;                            rt.intType =counter;                            rt.stringType = returnedString;                        }                        else{                            rt.stringType = rt.stringType +","+returnedString;                            rt.intType = counter;                        }                  }              } catch (Exception e) { }                                                                  return rt;       }       //**************************************************************************//         public ReturnType selectValue2 (String user) {                            ReturnType rt = new ReturnType();              int counter = 0;              boolean bool = false;              String returnedString = "";                            try {                                  String Query = "SELECT date FROM back_date where user_id ='"+user+"' ";                  rs = dbc.select(Query);                  while( rs.next() ) {                        String date = rs.getString("date");                        String[] temp1;                                              temp1 = date.split("-");                        String month = temp1[1];                        if(month.equals("01")) month = "Jan";                        if(month.equals("02")) month = "Feb";                        if(month.equals("03")) month = "Mar";                        if(month.equals("04")) month = "Apr";                        if(month.equals("05")) month = "May";                        if(month.equals("06")) month = "Jun";                        if(month.equals("07")) month = "Jul";                        if(month.equals("08")) month = "Aug";                        if(month.equals("09")) month = "Sep";                        if(month.equals("10")) month = "Oct";                        if(month.equals("11")) month = "Nov";                        if(month.equals("12")) month = "Dec";                        String tempDate = temp1[2] + "-" + month + "-" + temp1[0];                        returnedString = tempDate;                        counter ++;                        if (!bool){                            bool=true;                            rt.intType =counter;                            rt.stringType = returnedString;                        }                        else{                            rt.stringType = rt.stringType +","+returnedString;                            rt.intType = counter;                        }                  }              } catch (Exception e) { }                                        return rt;       }         //********************************************************************//        public String Validate ( String user) throws SQLException {                        String Query = "select user_id from user where user_id = '"+user+"'";            String msg = null;            rs = dbc.select(Query);            if (rs.next()){                msg = "SUCCESS";            }            else {                msg = "FAILURE";            }                        return msg;        }        public String CheckCurrentDateData ( String user, java.util.Date date) throws SQLException {                        java.sql.Date mydate = new java.sql.Date(date.getTime());            String Query = "select * from back_up where user_id ='"+user+"' AND back_date ='"+mydate+"' ";            rs = dbc.select(Query);            if (rs.next()) {                String Query1 = "delete from back_up where user_id ='"+user+"' AND back_date ='"+mydate+"'";                dbc.delete(Query1);                String Query2 = "delete from back_date where user_id ='"+user+"' AND date ='"+mydate+"'";                dbc.delete(Query2);            }                        return "abc";        }        public void DeleteTemp() throws SQLException {              String Query = "truncate table temp";              dbc.delete(Query);                     }}class ReturnType {      public String stringType;      public int intType ;      public ReturnType () {}  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -