现在,由于日新月异的发展,我们的数据库版本越来越高,但是对于高版本的MySQL/MariaDB,(针对Mysql5.7及其以上),对于注册账号时候,因为使用了存储过程,调用需要权限,而且对于字段校验极为严格,所以,在注册的时候会提示MySQL连接失败,其实就是其中的注册时间字段校验不严格导致。
首先,打开accont.jsp,在最前面引入所需要的
<%@page import="java.text.*"%>
引入后完整:
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@page import="java.security.*"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="GBK"%>
<%@include file="WEB-INF/.pwadminconf.jsp"%>
然后找到
String password = request.getParameter("password");
在后面插入:
String now=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime());
然后搜索:
password = pw_encode(login + password, MessageDigest.getInstance("MD5"));
在后面一句修改为
rs = statement.executeQuery("call adduser('" + login + "', " + password + ", '0', '0', '0', '0', '" + mail + "', '0', '0', '0', '0', 'GM', '0', '0', '" + now + "', '', " + password + ")");
至此,大功告成!!!