Link to a database error analysis

First of all, I created a table to enter information page

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>当前位置:添加学生信息Login</title>

<Script>
function Submit ()
{
var S;
S = login.user;
IF (s.value == "")
{Alert ( "username is not empty, registration failed");}
s.focus ();
}
function youxiang ()
{
var S;
var A, B;
A = s.indexOf ( "@");
B s.indexOf = ( ",");
 IF (A == B == -1 -1 || A ||> B)
Alert ( "input error");
the else IF (s.indexOf ( "@", A +. 1)! = -. 1)

 alert ( "input error");

}
</script>
</head>
<body>
<table align="center" border="2" width="400" >

<tr>
<td colspan="2" align=center><b>注册 </b><onclick="this.value=''/td>
</tr>

<td>登录账号:</td>
<td><input type="text" name="user"></td> <!-- 必须有value -->
</tr>

<td>学号</td>
<td><input type="text" name="usernode"></td>
</tr>
<td>登陆密码</td>
<td><input type="password" name="paw"></td>
</tr>
<td>性别</td>
<td>
<select type="a1"><option value="男" selected>男</option>
<option value="女">女</option>
</select>
</td>
</tr>
<td>姓名:</td>
<td> <input type = " text" name = "yourname"> </ td> <-! There must be value ->
</ TR>
<td> Email: </ td>
<td> <the INPUT of the type = "text" name = "email "> </ td> <-! there must be value ->
</ TR>
<td> the colleges, classes </ td>
<td> <the SELECT name = "s1"> <option value = "information Science" selected> Institute of information </ the Option>
<option value = "SEM"> SEM </ the Option>
<option value = "Mechanical and Electrical Engineering"> Mechanical and Electrical Engineering </ the Option>
<the Option value = "traffic School"> transportation College </ the Option>
<the Option value = "Forestry College"> Forestry College </ the Option>
<the Option value = "College"> College </ the Option>
</ the SELECT>
<select name = "s2"> < option value = " Computers" Selected> Computers </ Option>
<Option value = "Software professional"> software professional </ Option>
<Option value = "Information Management professional"> Information Management Professional < / the Option>
<the Option value = "landscape Architecture"> landscape Architecture </ the Option>
</ the SELECT>
<select name="s3"><option value="1班" selected>1班</option>
<option value="2班">2班</option>
<option value="3班">3班</option>
<option value="4班">4班</option>
<option value="5班">5班</option>
<option value="6班">6班</option>
</select>
</td>
</tr>
<td>入学年份</td>
<td><select name="year"><option value="1999" selected>1999</option>
<option value="2000">2000</option>
<option value="2001">2001</option>
<option value="2002">2002</option>
</select>
</tr>
<td>生源地:</td>
<td><input type="text" name="weizhi"></td> <!-- 必须有value -->
</tr>
<td>备注:<td><textarea cols=25 rows=3 name="intr"></textarea></td>
</tr>
<td colspan="2" align="center"><input type="button" value="提交" onclick="submit()" />
<input type="reset" value="重置" />
</tr>
</form>
</table>
</body></html>

 

To create such a form

then

<%@page import="org.apache.tomcat.util.descriptor.web.LoginConfig"%>
<%@page import="org.apache.catalina.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*"%>
<%@ page import="java.sql.*"%> <%--导入java中的sql包--%>
<%@page import="zhuce3.DBUtil"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

</head>
<body>
<%
String name=request.getParameter("user");//登陆
String usernode=request.getParameter("usernode");//学号
String paw=request.getParameter("paw");//密码
String sex=request.getParameter("sex");//性别
String yourname=request.getParameter("yourname");//姓名
String email=request.getParameter("email");//电子邮件
String s1=request.getParameter("s1");//学院
String s2=request.getParameter("s2");//班级
String s3=request.getParameter("s3");//专业
String year=request.getParameter("year");//入学年份
String weizhi=request.getParameter("weizhi");//生源地
String intr=request.getParameter("intr "); // NOTE out.print (" The login name has been registered "+" <br> ");
IF (name.equals (" the User ")) {

out.print("登陆名:"+name+"<br>");
out.print("学号:"+usernode+"<br>");
out.print("密码:"+paw+"<br>");
out.print("性别 :"+sex+"<br>");
out.print("姓名:"+yourname+"<br>");
out.print("邮件 :"+email+"<br>");
out.print("学院: "+s1+"<br>");
out.print("班级: "+s2+"<br>");
out.print("专业: "+s3+"<br>");
out.print("入学年份: "+year+"<br>");
out.print("生源地: "+weizhi+"<br>");
out.print("备注: "+intr+"<br>");

}
else if(name.equals("admin")){ %>

<Div align = "center"> Welcome to your administrator! </ Div>

<%}
The else {%>
<div align = left = "Center"> registered successfully! </ Div>

<% }
%>

</body>

</html>

As a guide through which the intermediate store into the database

But because the database has not been built, the beginning has been displayed 404

 

 

 

 Use eclipse tomcat configuration under the Mac's startup tomcat service successfully, but the access localhost: 8080 time is always reported 404 errors

1. stopped mysql: service mysqld stop

2. Use the state does not validate the login mysql:    

          mysqld_safe --skip-grant-tables & // background

          Start mysql: service mysqld start

3. Go to mysql: mysql -u root

4.use mysql;

5. update user set password = password ( "new_pass") where user = "root"; // 'new_pass' where you want to set a password

or

5.delete from user where user = ''; delete user space

 

6,flush privileges;

7,quit

8.service mysqld restart

9. Re-enter the mysql -utoot -p

original link: https: //blog.csdn.net/zhaofuqiangmycomm/article/details/83061197

 

Guess you like

Origin www.cnblogs.com/sunhongbin/p/11716005.html