I didn't use the label of JSP this time. The purpose is to use the bean to implement the calling method inside the Oracle process with the Eclipse editing JSP before implementation. JavaBean DataInst:
/ *
* CREATED ON 2004-11-4
*
* Todo to change the Template for this generated file go to
* WINDOW - Preferences - Java - Code Style - Code Templates
* /
/ ** * @author Shaird * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates * / import java.sql *; import javax.sql *; import.. Javax.naming. *;
/ ** * @author Shaird * * TODO using the process of inserting data * / public class DataInset {private int EmpId; private String EmpName; private String EmpDept; private int EmpAge; private boolean EmpIdOk; private boolean EmpNameOk; private boolean EmpDeptOk; private boolean Empageok;
/ ** * Set the employee ID. * @Param EMP_ID * / PUBLIC VOID STEMPID (INT EMP_ID) {this.empid = EMP_ID; Empidok = true;} / ** * Gets the employee ID. * @Return * / private int getETempid () {return this.empid;} / ** * Setting the employee name. * @Param EMP_NAME * / Public Void setEmpname (String Emp_name) {this.empname = EMP_NAME; EmpNameok = true;} / ** * Gets the employee name. * @Return * / public string getEmpname () {return this.empname;} / ** * Sets the department where employees are located. * @Param EMP_DEPT * / PUBLIC VOID STEMPDEPT (String Emp_DEPT) {this.empdept = EMP_DEPT; Empdeptok = true;} / ** * Gets the employee's department information. * @Return * / public string getempdept () {return this.empdept;}
/ ** * Set an employee age. * @Param EMP_AGE * / PUBLIC VOID STEMPAGE (INT EMP_AGE) {this.empage = EMP_AGE; Empageok = true;} / ** * Get an employee age. * @Return * / public int geTempage () {return this.empage;} / ** * Check is complete. * @Return * / public boolean isok () {if (Empidok && EmpNameok && Empdeptok && EmpageOK) {Return True;} / ** * Send Employee Information to the process. * @Throws java.io.IOException * / public void SendInfo () throws java.io.IOException {DataSource ds = null; try {InitialContext ctx = new InitialContext (); ds = (DataSource) ctx.lookup ( "java: comp / env / jdbc / oracle "); connection conn = ds.getConnection ();
CallableStatement Empstmt = conn.preparecall ("{call Emp_test (?,?,?,?)}"); Empstmt.setint (1,101); Empstmt.setString (2, "Zhang San"); Empstmt.setString (3, " Personnel Department "); Empstmt.Setint (4, 36); Empstmt.executeUpdate ();
CTX.Close (); conn.close ();} catch (throwable tt) {}}}
Call this bean JSP:
<% @ page language = "java" contenttype = "text / html; charset = GB2312"%> <% @ Page Import = "java.sql. *"%> <% @ page import = "javax.sql. *" %> <% @ page import = "javax.naming. *"%>