【解决思路】HTTP Status 500 Type Exception ReportMessage Request processing failed; 【已解决】

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 经常测试的一个网页,突然报错500。前面也没有发生过,但突然报错,只能先改错了,不然都没法进入页面。为什么会调用到存在bug的语句,而以前没有发生这种情况?这一问题没能想清楚,只能归咎于编译器了。

目录

零、前言

一、看错误提示

二、分析错误

三、定位问题

四、解决问题

1.png

Type Exception Report
Message Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 
PreparedStatementCallback; bad SQL grammar [delete from user_detail where username=?]; nested exception 
is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'username' in 'where clause'
Description The server encountered an unexpected condition that prevented it from fulfilling the request.


零、前言


      经常测试的一个网页,突然报错500。前面也没有发生过,但突然报错,只能先改错了,不然都没法进入页面。为什么会调用到存在bug的语句,而以前没有发生这种情况?这一问题没能想清楚,只能归咎于编译器了。


      百度了很多,发现有很多类似的报错,但大家的错误并不一样。问题的产生都是个例,不能生搬硬套,需要根据错误提示和自己的工程代码对应进行改正。其他博主均是指出自己遇到的错误,并解决之,让新手的我看得似懂非懂,最后问题还是没解决。为此,我摸索了许久,终是解决了,在这里详细解释一下解决思路,如此也能给他人解决自己遇到的问题提供思路和方法。


一、看错误提示


Cause:

1、org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [delete from user_detail where username=?]

2、com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'username' in 'where clause'


二、分析错误


      这里面涉及到了SQL语句,然后Unknown column 'username' in 'where clause'这说明是SQL语句与数据库表结构不统一导致的问题!即原因是未知的字段“username”,user_detail表中缺少字段!

首先在mysql中显示user_detail表结构和内容:

1.png

发现的确少了username字段。(为什么缺少该字段还要去操作该字段呢?)


三、定位问题


      这里面user_detail表缺少字段username,是由于第一个问题中在user_detail表内操作了username字段。其实发生错误第一个错误往往是解决问题的关键,因此就去查询一下操作位置,发现delete操作是需要根据users表一起对应删除username的用户信息。而users表中是username

字段,而对应user_detail表中对应为real_name字段,从而引发的错误。

users表结构:

1.png


四、解决问题


找到调用函数位置,调用了removeUserDetail,然后对应找到removeUserDetail定义位置,并修改其中的操作字段。

//删除
userService.removeUser(localname);
userService.removeUserDetail(localname);

改正之前:

public void removeUserDetail(String userName){
    String sql = "delete from " + ModelMeta.USER_DETAIL
            + " where username=?";
    this.genericEntityDao.update(sql, new Object[] { userName });
}

改正之后:

1.public void removeUserDetail(String userName){
    String sql = "delete from " + ModelMeta.USER_DETAIL
            + " where real_name=?";
    this.genericEntityDao.update(sql, new Object[] { userName });
}

修改后,HTTP  Status 200就能正常访问页面了。

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
7月前
|
移动开发 负载均衡 安全
Web Security 之 HTTP request smuggling(上)
Web Security 之 HTTP request smuggling
120 0
|
2月前
|
机器学习/深度学习 前端开发 JavaScript
源映射错误:Error: request failed with status 404 源 URL:http://localhost:8080/bootstrap/js/axios-0.18.0.js
源映射错误:Error: request failed with status 404 源 URL:http://localhost:8080/bootstrap/js/axios-0.18.0.js
43 0
源映射错误:Error: request failed with status 404 源 URL:http://localhost:8080/bootstrap/js/axios-0.18.0.js
|
7月前
|
网络安全
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://xxxx.svc.cluster.local:8080/xxxx": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "xxxx.svc.cluster.local:8080/xxxx ": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
917 0
|
5月前
|
JSON 小程序 前端开发
小程序踩坑-http://xxx.com 不在以下 request 合法域名列表中
小程序踩坑-http://xxx.com 不在以下 request 合法域名列表中
132 0
|
2月前
|
存储 Web App开发 缓存
【JavaEE初阶】 HTTP 请求 (Request)详解
【JavaEE初阶】 HTTP 请求 (Request)详解
|
6月前
|
Java 容器
RestTemplate报错I/O error on POST request for "http://crmjob.xxx.xxx.com/removeJob": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out问题处理
讲述RestTemplate报错I/O error on POST request for "http://crmjob.xxx.xxx.com/removeJob": Read timed out; nested exception is java.net.SocketTimeoutException: Read timed out处理方案
|
7月前
|
XML 开发框架 Java
Java Web 项目入门指南(http、Servlet、Request、Response、ServletContext、会话技术[cookie、session]、Filter、Listener)
Java Web 项目入门指南(http、Servlet、Request、Response、ServletContext、会话技术[cookie、session]、Filter、Listener)
|
2月前
|
小程序
报错:http://edu.newsight.cn不在以下request合法域名列表中,请参考文档
报错:http://edu.newsight.cn不在以下request合法域名列表中,请参考文档
HTTP request以及response原理 request请求消息数据
HTTP request以及response原理 request请求消息数据