📄 personlog.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!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=gb2312">
<title>无标题文档</title>
</head>
<body>
<%request.setCharacterEncoding("gb2312");%>
<%
try{
String person_id=request.getParameter("person_id");
String personname=request.getParameter("personname");
String target_type=request.getParameter("target_type");
String sex=request.getParameter("sex");
String identify=request.getParameter("identify");
String phone=request.getParameter("phone");
String number=request.getParameter("number");
String mobile_phone=request.getParameter("mobile_phone");
String zipcode=request.getParameter("zipcode");
String address=request.getParameter("address");
if(person_id.equals("")){
String redirctURL="person.jsp";
response.sendRedirect(response.encodeURL(redirctURL));
out.print("<script>alert('请输入用户ID!');window.location.href='person.jsp'</script>");
}
else{
String sqlquerystring="SELECT person_id FROM Person_info";
sqlquerystring+=" "+"WHERE person_id LIKE"+""+"'"+person_id+"'";
String driver= "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver).newInstance();
String ConURL = "jdbc:odbc:login";
Connection con = null;
con = DriverManager.getConnection(ConURL,"sa","453558337");
Statement stmt = con.createStatement();
ResultSet rs = null;
rs = stmt.executeQuery(sqlquerystring);
if(rs.next()){
if(rs.getString(1).trim().equals(person_id.trim()))out.print("<script>alert('联系人号已存在请从新输入');window.location.href='vehicleinsurance.jsp'</script>");
if(target_type.equals("")){
String redirctURL="person.jsp";
response.sendRedirect(response.encodeURL(redirctURL));
out.print("<script>alert('请选择用户联系标的类型:!');window.location.href='person.jsp'</script>");
}
else{
if(target_type.trim().equals("1")){
String redirectURL="vehicleinsurance.jsp";
response.sendRedirect(response.encodeURL(redirectURL));
}
}
rs.close();
stmt.close();
con.close();
}
else{
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
sqlquerystring="SELECT * FROM Person_info";
rs=stmt.executeQuery(sqlquerystring);
rs.last();
rs.updateString(1,person_id);
rs.updateString(2,personname);
rs.updateString(3,target_type);
rs.updateString(4,sex);
rs.updateString(5,identify);
rs.updateString(6,phone);
rs.updateString(7,number);
rs.updateString(8,mobile_phone);
rs.updateString(9,zipcode);
rs.updateString(10,address);
rs.insertRow();
SQLWarning warn=rs.getWarnings();
if(warn!=null){
out.println("---------------Warning-----------");
out.println("<br>");
while(warn!=null){
out.println("Message:"+warn.getMessage());
out.println("<br>");
out.println("SQLState:"+warn.getSQLState());
out.println("<br>");
out.println("Vendor error code:");
out.println("<br>");
warn=warn.getNextWarning();
}
}
rs.close();
stmt.close();
con.close();
String redirectURL="person.jsp";
response.sendRedirect(response.encodeURL(redirectURL));
}
}
}
catch(SQLException ex) {
out.println("SQLException caught");
out.println("<br>");
while(ex!=null){
out.println("Message:"+ex.getMessage());
out.println("<br>");
out.println("SQLState:"+ex.getSQLState());
out.println("<br>");
out.println("ErrorCode:"+ex.getErrorCode());
out.println("<br>");
ex=ex.getNextException();
}
}
%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -