Call the Bean in the JSP and invoke the Oracle stored procedure in the bean

Source: Internet
Author: User

Novice in writing program, must be adventurousness, and must have patience, do not compromise, do not understand on the book, online search data, ask friends, resolutely carried out in the end.

Recently has been with the knowledge of the ASP in the groping forward, a run bumpy, since needless to say. Anyway

Establish a login system that requires the following purposes.

1, the user through the bean to authenticate and get the user information.

2, record user login information, such as user login times, the last logon time.

3, record the operation log.

Unresolved and puzzling questions:

1, the user login after the session can be judged by the bean.

2. Call the Oracle stored procedure through the bean and return the recordset after the select.

Operation Steps:

1. Establish user authentication Bean:

 public boolean checkUser() throws Exception {
  boolean flag=false;
  ResultSet rs=conn.executeQuery(getSql());
  if(rs.next()){
   userID    =rs.getString("userID");
   userName   =rs.getString("userName");
   userPWD    =rs.getString("userPWD");
   userUnit   =rs.getString("userUnit");
   userLoadTime =rs.getDate("userLoadTime");
   userLoadNumeric=rs.getInt("userLoadNumber");
   flag=true;
  }
  rs.close();
  conn.closeConn();
  return flag;
 }

Determines whether a user exists by the value returned.

2, record the user login information:

public void changeLoginInfo(String userID) throws Exception{
  String sql="update SystemUserTable set UserLoadTime=sysdate,UserLoadNumber=UserLoadNumber+1 where userID='"+userID+"'";
  conn.executeUpdate(sql);
 }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.