Saturday, December 26, 2015

Encrypt And Decrypt ( Actual text)


http://www.online-toolz.com/tools/text-encryption-decryption.php

Decrypt ( Actual text) = java



Encrypt Text ( it is java's Encrypt  text) :
u4VA+Izvqyuo2fBJowYDLxv9sh0gHfBGoHLTLtsxpF4=



Get Session Value ::
     //int userid = (Integer) ActionContext.getContext().getSession().get("userId");//From gpK
        ActionContext.getContext().getSession().put("usernameF",username==null?"":username.trim());
        ActionContext.getContext().getSession().put("passwordF",password==null?"":password.trim());


Some SQL Study ::      
 //31102015 Paegnancy Day Form
        public String addPregnancyDay(String language_type, String days_day, String weeks_day, String months_day, String text_day){

            String messageSendS="";
            boolean fg = true;
            con = dbc.connectDB();
            String query ="";
            int count_role=0;

            if (con == null) {
                fg = false;
            }

            if (fg) {
                try {
//                    if(days_day.trim().isEmpty()){
                        st = con.createStatement();
                         String querySelect ="   SELECT DAYS FROM eh_pgncydwclndr WHERE DAYS = '"+days_day+"' ";
                        System.out.println(querySelect);
                        ResultSet rs = st.executeQuery(querySelect);
                        while(rs.next()){
                            count_role=rs.getRow();
                        }
                        if(count_role<=0){
                            //            st = con.createStatement();
                            ///-------------------
                            if(language_type.equals("en")){
                               
                                  query = "insert into  eh_pgncydwclndr(days , weeks, months, dwtexts) "
                                            + " values ('"+days_day+"','"+weeks_day+"','"+months_day+"','"+text_day+"') ";
                                    System.out.println("Insert Paegnancy Day :" +query);
                                  st.executeUpdate(query);
                                   
                                }else{
                                    query = "insert into  eh_pgncydwclndr(days , weeks, months, dwtexts_"+language_type+") "
                                            + " values ('"+days_day+"','"+weeks_day+"','"+months_day+"','"+text_day+"') ";
                                    System.out.println("Insert Paegnancy Day :" +query);
                                    st.executeUpdate(query);
                                }
                                       messageSendS="Data Saved Successfully";
                           
                            ///---------
                        }else{
                            //**********************************
                            if(language_type.equals("en")){
                                String updateSQL="UPDATE eh_pgncydwclndr"
                                        + " SET dwtexts = '"+text_day+"'" 
                                        + " WHERE days = '"+days_day+"'"
                                        + " and  weeks = '"+weeks_day+"'"
                                         + " and  months=  '"+months_day+"'";
                                   
                                     System.out.println(updateSQL);
                                     st.executeUpdate(updateSQL);
                            }else{
                               
                                String updateSQL="UPDATE eh_pgncydwclndr"
                                        + "  SET dwtexts_"+language_type+" = '"+text_day+"'" 
                                        + "  WHERE days = '"+days_day+"'"
                                        + "  and  weeks = '"+weeks_day+"'"
                                         + "  and  months=  '"+months_day+"'";
                                   
                                     System.out.println(updateSQL);
                                     st.executeUpdate(updateSQL);
                            }
                                       //*************************
                           
                        }

                       
//                                }


                } catch (SQLException sq) {
                    sq.printStackTrace();
                     messageSendS="Database Error";
                    System.out.println("Company Name Query Exception "+sq.getMessage());
                } finally {
                    try {
                        if (rs != null) {
                            rs.close();
                        }

                        con.close();
                    } catch (SQLException ex) {
                        ex.printStackTrace();
                    }
                }
            }

            return messageSendS;
        }



//Cheif Complain Insert
          
            public String addChiefComplain(String language_type, String chief_complain_id, String chief_complain, String status, String body_position, String gender ,String emp_no){

                String messageSendS="";
                boolean fg = true;
                con = dbc.connectDB();
                String query ="";
                if (con == null) {
                    fg = false;
                }
                if (fg) {
                    try {
                        if(chief_complain_id.trim().isEmpty()){
                            st = con.createStatement();
                            if(language_type.equals("en")){
                              chief_complain_id =generatedSequence("SEQ_CHIEF_COMPLAIN","",con);               
                              query = "insert into  lookup_chief_complain(chief_complain_id , chief_complain, body_position, company_no, active_status, gender,  CREATE_DATE) "// effect,
                                        + " values ('"+chief_complain_id+"','"+chief_complain+"','"+body_position+"','1','"+status+"','"+gender+"',sysdate ) ";//
                                System.out.println("Insert Chief Complaint :" +query);
                              st.executeUpdate(query);                           
                            }else{
                                chief_complain_id =generatedSequence("SEQ_CHIEF_COMPLAIN","",con);
                                query = "insert into  lookup_chief_complain(chief_complain_id , chief_complain_"+language_type+", body_position, company_no, active_status, gender,  CREATE_DATE) "// CREATED_BY,
                                        + " values ('"+chief_complain_id+"','"+chief_complain+"','"+body_position+"','1','"+status+"','"+gender+"',sysdate ) ";//'"+emp_no+"'
                                System.out.println("Insert Chief Complaint :" +query);
                                st.executeUpdate(query);
                            }
                                   messageSendS="Data Saved Successfully";                       
                        }else{
                            st = con.createStatement();
                            if(language_type.equals("en")){
                                String updateSQL="UPDATE lookup_chief_complain"
                                        + "   SET body_position = '"+body_position+"'," 
                                        + "       active_status = '"+status+"',"
                                        + "       UPDATE_DATE = sysdate,"
                                        + "       gender = '"+gender+"',"
                                         + "       chief_complain=  '"+chief_complain+"'"
                                        + " WHERE chief_complain_id = '"+chief_complain_id+"'";                       
                                     System.out.println(updateSQL);
                                     st.executeUpdate(updateSQL);
                            }else{                           
                                String updateSQL="UPDATE lookup_chief_complain"
                                        + "   SET body_position = '"+body_position+"'," 
                                        + "       active_status = '"+status+"',"
                                        + "       gender = '"+gender+"',"
                                        + "       update_date = sysdate,"                                   
                                        + "       chief_complain_"+language_type+" =  '"+chief_complain+"'"
                                        + " WHERE chief_complain_id = '"+chief_complain_id+"'";                       
                                     System.out.println(updateSQL);
                                     st.executeUpdate(updateSQL);
                            }
                           
                           
                        }


                    } catch (SQLException sq) {
                        sq.printStackTrace();
                         messageSendS="Database Error";
                        System.out.println("Company Name Query Exception "+sq.getMessage());
                    } finally {
                        try {
                            if (rs != null) {
                                rs.close();
                            }

                            con.close();
                        } catch (SQLException ex) {
                            ex.printStackTrace();
                        }
                    }
                }

                return messageSendS;
            }

  //Sequence

            public String generatedSequence(String param1, String param2,Connection con) {

                boolean flag = true;
                if (con == null) {
                    flag = false;
                }
                String result = "";
                if (flag) {
                    try {
                        cs = con.prepareCall("{call prc_pk(?, ?, ?) }");
                        cs.setString(1, param1);
                        cs.setString(2, param2);
                        cs.registerOutParameter(3, java.sql.Types.INTEGER);
                        cs.executeQuery();
                        result = cs.getString(3);
                    } catch (Exception e) {
                        System.out.println(e.toString());
                    }
                }
                return result;
            }

No comments:

Post a Comment