Jsp+javabean step-by-Step Tutorial (iv)

Source: Internet
Author: User

Application of database operation in JavaServer Pages+javabeans

The above has said a simple JavaBean application of the counter example, of course, in the actual program process, involves more and database-related operations, so in this section we will focus on JavaServer pages and JavaBeans How to operate the database. Here we have selected a more representative and practical example, that is the user registration management, because this is used on the Internet more frequently, whether it is registered email, award-winning survey, purchase items or join the community, etc. will involve a user registration problem; On the other hand, it is more representative, Related to the database record increase, record display and other common operations, so we take the user registration surgery.

The program uses the Oracle Jdeveloper3.1 development, the operating environment is wiin2000+tomcat3.1, the database system uses the oracle8.16i.

First we set up a database Demodb, and the fields are as shown below

Username VARCHAR2 (20) User name
Password VARCHAR2 (20) password
Email VARCHAR2 (email address)
Homepage VARCHAR2 (50) Home
Signs VARCHAR2 (200) signature
Regtime Date Registration Time

Then we build several JavaBeans and JavaServer pages files

Db.java files (encapsulates database connections and some underlying operations)
Adduser.java files (for user data reading and adding operations)
newuser.jsp file (user new page, for entering user registration information)
donewuser.jsp files (add for user registration information)
listuser.jsp file (all registered user Information list)

In order to facilitate everyone to see the code, in many places have been detailed comments and explanations, as for JavaBean in the Java grammar structure of things, please refer to Java books.

Db.java file

Description: This JavaBean encapsulates database connections and some underlying operations, derived classes can call these methods directly, and provides a Tochinese method, which is mainly used for processing Chinese data.

Copyright (c) http://jspbbs.yeah.net
Package Lyf;
/**
* A class class.
* $#@60; p$#@62;
* @author Liuyufeng
*/

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.