Use JavaBean to implement the calling process

xiaoxiao2021-03-06  101

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. *"%> with bean call Procedure </ title> </ head> <body> <table> <tr> <td> Employee ID </ td> <td> Employee Name </ TD> <TD> Office </ TD> <TD> Employee Age </ td> <TD> Registration time </ td> </ tr> <% datainset nesed = new dataset (); need.seTempid (101); need.sempname ("Zhang San"); Need.semetempdept ("Personnel Department); Need.sempage (36); Need.sendinfo (); DataSource DS = NULL; InitialContext CTX = New InitialContext (); DS = (DataSource) CTX.lookup ("Java: Comp / Env / JDBC / Oracle" ); Connection conn = ds.getConnection (); statement stmt = conn.createstatement (); resultset = stmt.executeQuery ("select * from emp_info_test");</p> <p>While (rs.next ()) {OUT.Println ("<TD>" rs.getstring (1) </ td> <TD> " rs.getstring (2) " </ TD > <TD> " rs.getstring (3) </ TD> <TD>" rgetstring (4) </ td> <td> " rs.getstring (5) " </ TD> </ TR> ");</p> <p>CTX.Close (); rs.close (); stmt.close (); conn.close ();%> </ table> <% = need.isok ()%> <p> </ body> </ html ></p> <p>When you want to insert this data in the OK, you can just call this bean.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-96114.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="96114" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.054</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'T7hns4FySHa1SMoRvI4knqPFlOVHxlwqGuwhursrjuL4deReRfQNs38RK7BeYfBcE9zDn_2Flef40ezWUUQcCk0g_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>