Two common forms of data storage processing methods
1, for each form to write the appropriate program code
In a JSP page or JavaBean or servlet, use request. The GetParameter () function extracts the data submitted by the form individually, or writes the corresponding JavaBean, uses the SetProperty method to automatically fetch the data into the JavaBean, and then generates the SQL statement (Insert,update,delete). Finally, execute the executeupdate () function to complete the data table store.
2. Automatically generate a JavaBean program code for each datasheet
The database system must support the ability of users to read the table structure and identify key fields. Using object-oriented rapid development tools, such as PowerBuilder, Delphi, and so on, the development of a Java code automatic generation program. Read the structure of the database table in the Program: field name, data type, data length, and automatically generate a JavaBean code. In this code, define the variable with the same name as the field in the table, establish the SetValue and GetValue methods for all the variables, and establish the INSERT, update, and delete functions to handle the SQL statement generation and execution of INSERT, UPDATE, delete, respectively.
In the Data processing page submitted by the form, write the following code to store the form data in JavaBean:
<jsp:useBean id="table" class="table1_bean" />
<jsp:setProperty name="table" property="*" />
(注:table1_bean为上述自动生成的对应某一个表的JavaBean)