0
votes

i need make login page connected with database table in j developer 12.2.1.2, i hope any one give me any article or book or videos or any method to do login page connected with database table.

3

3 Answers

0
votes

You can use this simple approach: https://blogs.oracle.com/shay/entry/for_some_reason_one_common

Although a more complete solution would be to use that RDBMS Authentication Providers for WebLogic: https://docs.oracle.com/cd/E21764_01/web.1111/e13707/atn.htm#SECMG190

0
votes

I have used simple approach for this scenario https://blogs.oracle.com/shay/entry/for_some_reason_one_common

I think this will be very helpfull to you

0
votes

I use javaBean

Example Code

public String loginAction() throws SQLException {

    FacesContext facesContext;
    facesContext = FacesContext.getCurrentInstance();
    UIViewRoot root = facesContext.getViewRoot();
    RichInputText inputUser = (RichInputText)root.findComponent("it1");
    String userName = inputUser.getValue().toString().toUpperCase();

    RichInputText inputPass = (RichInputText)root.findComponent("it2");
    String passWords = inputPass.getValue().toString();

    String chT = "0" ;
    String sqlCheck ;
    sqlCheck = "Select trim(to_char(count(*))) N From tbUserName u where u.USER_NAME = '"+ userName +"' and u.USER_PASSWORD = '"+ passWords +"'" ;

   System.out.print(sqlCheck.toString());

    try{

        Connection ConnCheck;
        ResultSet RsCheck ;

        Statement stmtCheck ;

        ConnCheck = getConnection();
        stmtCheck = ConnCheck.createStatement();
        RsCheck =  stmtCheck.executeQuery(sqlCheck);

        while(RsCheck.next())  {

            if(RsCheck.getString(1).equals("1")){

                chT = RsCheck.getString(1).toString(); 

            }else{

                chT = RsCheck.getString(1).toString(); 

            }
        }

        ConnCheck.close();

        if(chT.equals("1")){

            if(createSessionAll(userName)){

                FacesContext.getCurrentInstance().getExternalContext().redirect("home.jsf");

            }else{
                String MsgText = "Create Session Fail!!! ";
                FacesMessage fm = new FacesMessage(MsgText);
                fm.setSeverity(FacesMessage.SEVERITY_ERROR);
                FacesContext conTxt = FacesContext.getCurrentInstance();
                conTxt.addMessage(null, fm);
            }

        }else{

            String MsgText = "Login Fail Check User/Pass!!! ";
            FacesMessage fm = new FacesMessage(MsgText);
            fm.setSeverity(FacesMessage.SEVERITY_ERROR);
            FacesContext conTxt = FacesContext.getCurrentInstance();
            conTxt.addMessage(null, fm);
        }


    }catch (Exception e) {

        String MsgText = "Error Somthing ";
                        FacesMessage fm = new FacesMessage(MsgText);
                        fm.setSeverity(FacesMessage.SEVERITY_ERROR);
                        FacesContext conTxt = FacesContext.getCurrentInstance();
                        conTxt.addMessage(null, fm);
        e.printStackTrace();
    } 

    return null;
}