当前位置: 代码迷 >> Eclipse >> 如何和数据库连接
  详细解决方案

如何和数据库连接

热度:19   发布时间:2016-04-23 14:41:59.0
怎么和数据库连接 ?
如何将登陆截面和数据库连接呢?
<jsp:useBean   id= "alogin "   scope= "page "   class= "org.pan.web.login "   />
<%
String   mesg   =   " ";

if(   request.getParameter( "username ")!=null   &&   !request.getParameter( "username ").equals( " ")){
String   username   =request.getParameter( "username ");
String   passwd   =   request.getParameter( "passwd ");
username   =   new   String(username.getBytes( "ISO8859-1 "));
passwd   =   new   String(passwd.getBytes( "ISO8859-1 "));
alogin.setUsername(username);
alogin.setPasswd(passwd);
if   (alogin.excute()){
session.setAttribute( "username ",username);
String   userid   =   Long.toString(alogin.getUserid());
session.setAttribute( "userid ",userid);
response.sendRedirect( "userinfo.jsp ");
%>
<%
}else   {
mesg   =   "登录出错! " ;
}
}
%>

<!DOCTYPE   HTML   PUBLIC   "-//W3C//DTD   HTML   4.01   Transitional//EN ">


<html>
    <head>
        <base   href= " <%=basePath%> ">
       
        <title> Bookstore   login.jsp </title>
       
<meta   http-equiv= "pragma "   content= "no-cache ">
<meta   http-equiv= "cache-control "   content= "no-cache ">
<meta   http-equiv= "expires "   content= "0 ">        
<meta   http-equiv= "keywords "   content= "keyword1,keyword2,keyword3 ">
<meta   http-equiv= "description "   content= "This   is   my   page ">
<!--
<link   rel= "stylesheet "   type= "text/css "   href= "styles.css ">
-->
<script   language= "javascript ">

  function   checkform()   {
if   (document.form1.username.value== " "   ||   document.form1.passwd.value== " "){
alert( "用户名或密码为空! ");
return   false;
}
return   true;

    }

</script>
    </head>
   
    <body>
        <body   bgcolor= "#FFCC99 "   text= "#000000 ">
<div   align= "center ">
    <table   width= "750 "   border= "0 "   cellspacing= "1 "   cellpadding= "1 ">
        <tr>  
            <td   width= "120 "   align= "center "> <img   src= "images/Img20625.jpg "   width= "50 "   height= "50 "> <br>
                <font   color= "#0066cc "> &#32593;&#32476;&#30005;&#23376;&#20070;&#22478; </font> <br> </td>
            <td   align= "center "> <img   src= "images/baners2.gif "   width= "468 "   height= "60 "> </td>
  相关解决方案