registerandlogin.zip

  • 涛声依旧88
    了解作者
  • Java
    开发工具
  • 26KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 2
    下载次数
  • 2014-12-29 23:11
    上传日期
servlet和jsp实现用户的登陆和注册功能
registerandlogin.zip
  • registerandlogin.docx
    28.9KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/622b9daf3d2fbb0007ef1448/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b9daf3d2fbb0007ef1448/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">&#25968;&#25454;&#24211;</div><div class="t m0 x1 h4 y3 ff2 fs1 fc1 sc0 ls0 ws0">drop<span class="fc0"> </span>table<span class="fc0"> </span>if<span class="fc0"> </span>exists<span class="fc0"> t_user;</span></div><div class="t m0 x1 h4 y4 ff2 fs1 fc1 sc0 ls0 ws0">create<span class="fc0"> </span>table<span class="fc0"> t_user(</span></div><div class="t m0 x1 h4 y5 ff2 fs1 fc0 sc0 ls0 ws0">id <span class="fc1">bigint</span> <span class="fc1">primary</span> <span class="fc1">key</span> auto_increment,</div><div class="t m0 x1 h4 y6 ff2 fs1 fc0 sc0 ls0 ws0">username <span class="fc1">varchar</span>(50) <span class="fc1">unique</span>,</div><div class="t m0 x1 h4 y7 ff2 fs1 fc1 sc0 ls0 ws0">name<span class="fc0"> </span>varchar<span class="fc0">(50),</span></div><div class="t m0 x1 h4 y8 ff2 fs1 fc0 sc0 ls0 ws0">pwd <span class="fc1">varchar</span>(20),</div><div class="t m0 x1 h4 y9 ff2 fs1 fc0 sc0 ls0 ws0">gendar <span class="fc1">char</span>(1)</div><div class="t m0 x1 h4 ya ff2 fs1 fc0 sc0 ls0 ws0">);</div><div class="t m0 x1 h4 yb ff2 fs1 fc1 sc0 ls0 ws0">select<span class="fc0"> * </span>from<span class="fc0"> t_user;</span></div><div class="t m0 x1 h5 yc ff3 fs0 fc0 sc0 ls0 ws0">package da<span class="_ _0"></span>o;</div><div class="t m0 x1 h5 yd ff3 fs0 fc0 sc0 ls0 ws0">import jav<span class="_ _0"></span>a.sql.Connec&#58903;o<span class="_ _0"></span>n;</div><div class="t m0 x1 h5 ye ff3 fs0 fc0 sc0 ls0 ws0">import jav<span class="_ _0"></span>a.sql.Prepar<span class="_ _0"></span>edStat<span class="_ _0"></span>ement;</div><div class="t m0 x1 h5 yf ff3 fs0 fc0 sc0 ls0 ws0">import jav<span class="_ _0"></span>a.sql.ResultSe<span class="_ _0"></span>t;</div><div class="t m0 x1 h5 y10 ff3 fs0 fc0 sc0 ls0 ws0">import u&#58903;l.DBU&#58903;l;</div><div class="t m0 x1 h5 y11 ff3 fs0 fc0 sc0 ls0 ws0">import en&#58903;ty<span class="_ _1"></span>.User;</div><div class="t m0 x1 h5 y12 ff3 fs0 fc0 sc0 ls0 ws0">public class UserDA<span class="_ _0"></span>O {</div><div class="t m0 x2 h5 y13 ff3 fs0 fc0 sc0 ls0 ws0">public void sav<span class="_ _0"></span>e(User user) thro<span class="_ _0"></span>ws Ex<span class="_ _0"></span>cep&#58903;on {</div><div class="t m0 x3 h5 y14 ff3 fs0 fc0 sc0 ls0 ws0">Connec&#58903;on conn = DBU&#58903;l.getConnec&#58903;on();</div><div class="t m0 x3 h5 y15 ff3 fs0 fc0 sc0 ls0 ws0">PreparedSt<span class="_ _0"></span>ate<span class="_ _0"></span>ment ps = conn</div><div class="t m0 x4 h5 y16 ff3 fs0 fc0 sc0 ls0 ws0">.prepar<span class="_ _0"></span>eStat<span class="_ _0"></span>ement("insert<span class="_ _2"> </span> <span class="_ _2"> </span>into<span class="_ _2"> </span> <span class="_ _2"> </span>t_u<span class="_ _3"></span>ser(username,name,pwd,gendar)</div><div class="t m0 x1 h5 y17 ff3 fs0 fc0 sc0 ls0 ws0">values(?,?,?,?)");</div><div class="t m0 x3 h5 y18 ff3 fs0 fc0 sc0 ls0 ws0">ps.setString(1, user<span class="_ _4"></span>.getUsername());</div><div class="t m0 x3 h5 y19 ff3 fs0 fc0 sc0 ls0 ws0">ps.setString(2, user<span class="_ _4"></span>.getName());</div><div class="t m0 x3 h5 y1a ff3 fs0 fc0 sc0 ls0 ws0">ps.setString(3, user<span class="_ _4"></span>.getPwd());</div><div class="t m0 x3 h5 y1b ff3 fs0 fc0 sc0 ls0 ws0">ps.setString(4, user<span class="_ _4"></span>.getGenndar());</div><div class="t m0 x3 h5 y1c ff3 fs0 fc0 sc0 ls0 ws0">ps.ex<span class="_ _0"></span>ecute<span class="_ _0"></span>Update();</div><div class="t m0 x3 h5 y1d ff3 fs0 fc0 sc0 ls0 ws0">DBU&#58903;l.close(conn);</div><div class="t m0 x2 h5 y1e ff3 fs0 fc0 sc0 ls0 ws0">}</div><div class="t m0 x2 h5 y1f ff3 fs0 fc0 sc0 ls0 ws0">public User 6ndByUsername(String username) thro<span class="_ _0"></span>ws Ex<span class="_ _0"></span>cep&#58903;on {</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐