字段列表中的未知列 [英] unknown column in field list

查看:191
本文介绍了字段列表中的未知列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我获取更新值的代码块



this is my code block to get the updated values

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h3>Updated Successfuly!!</h3>

       <sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"

     url="jdbc:mysql://localhost:3306/mysql"

     user="root"  password="root"/>

        <sql:update dataSource="${snapshot}" var="result">
            UPDATE user_reg_ml SET  uname=${param.uname} ,email=${param.email} ,country=${param.country} where id=${param.id}
        </sql:update>
    <%--
        <sql:query var="result" dataSource="${snapshot}">
            select * from user_reg_ml where id=${param.id}
        </sql:query>
         <table>

        <c:forEach var="row" items="${res.rows}">
            <tr>
                <td>
                    ID
                </td>
                 <td>
                    ${row.id}
                </td>
            </tr>
            <tr>
                <td>
                    Name
                </td>
                <td>

                    ${row.uname}
                </td>
            </tr>
            <tr>
                <td>
                    Email
                </td>
                <td>
                    ${row.email}
                </td>
            </tr>
            <tr>
                <td>
                    Country
                </td>
                <td>
                    ${row.country}
                </td>
            </tr>
        </c:forEach>
    </table>
    --%>
    </body>
</html>









这是我的代码块编辑值







and this is my code block to edit values

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        Welcome ${uname}

     <form action="update_mypage.jsp" method="post">

<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"

     url="jdbc:mysql://localhost:3306/mysql"

     user="root"  password="root"/>

<sql:query dataSource="${snapshot}" var="result">
select * from user_reg_ml where uname='${param.uname}' and pwd='${param.pwd}'
</sql:query>
        <%--input type="hidden" name="user" value="${param.uname}"--%>

        <c:forEach var="row" items="${result.rows}">
            ID: <input type="text" name="id" value="${row.id}" ><br/>

            USERNAME:  <input type="text" name="uname" value="${row.uname}"><br/>

            EMAIL: <input type="text" name="email" value="${row.email}"><br/>

            COUNTRY: <input type="text" name="country" value="${row.country}"><br/>

        </c:forEach>

        <input type="submit" value="update">
</form>

    </body>
</html>







但是当我点击更新按钮时,我收到以下错误



HTTP St atus 500 - 内部服务器错误



类型异常​​报告



messageInternal服务器错误



说明服务器遇到内部错误,无法完成此请求。



例外

javax .servlet.ServletException:

UPDATE user_reg_ml SET uname = abc,email = abc @ gmail.com,country = India其中id = 1

:你的错误在你的身上SQL语法;查看与您的MySQL服务器版本对应的手册,以便在第1行附近的'@gmail.com,country = India,其中id = 1'附近使用正确的语法





根本原因

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:SQL语法中有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行附近的'@gmail.com,country = India,其中id = 1'附近使用正确的语法





note GlassFish Server开源版4.0日志中提供了异常的完整堆栈跟踪及其根本原因。




but when i click update button, i get following error

HTTP Status 500 - Internal Server Error

type Exception report

messageInternal Server Error

descriptionThe server encountered an internal error that prevented it from fulfilling this request.

exception
javax.servlet.ServletException:
UPDATE user_reg_ml SET uname=abc ,email=abc@gmail.com ,country=India where id=1
: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com ,country=India where id=1' at line 1


root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com ,country=India where id=1' at line 1


note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.

推荐答案

{快照} var = result >
UPDATE user_reg_ml SET uname =
{snapshot}" var="result"> UPDATE user_reg_ml SET uname=


{param.uname},email =
{param.uname} ,email=


{param.email},country =
{param.email} ,country=


这篇关于字段列表中的未知列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆