Unknown column 'nation' in 'field list' 找不到这个字段怎么回事 求大神解决下!!!

qq_41924365 2018-05-03 10:48:15
Unknown column 'nation' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1031)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2022)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1940)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1925)
at model.Model.usermessgeupdate(Model.java:154)
at Contorl.usermessgeServelt.doPost(usermessgeServelt.java:59)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)




//更新管理员的信息
public int usermessgeupdate(String name,String nation,String bridays,String idcard,String address,Integer phone,Integer tel,String emil,String belong,Integer code,String nowadress){
int i=0;
try {
conn=s.getConnection();
String sql="update studb set name=?,nation=?,bridays=?,idcard=?,address=?,phone=?,tel=?,emil=?,belong=?,code=?,nowadress=?";
ps=conn.prepareStatement(sql);
ps.setString(1, name);
ps.setString(2, nation);
ps.setString(3, bridays);
ps.setString(4, idcard);
ps.setString(5, address);
ps.setInt(6, phone);
ps.setInt(7, tel);
ps.setString(8, emil);
ps.setString(9, belong);
ps.setInt(10, code);
ps.setString(11, nowadress);
i=ps.executeUpdate();
s.closeAll(conn,ps,rs);
} catch (SQLException e) {
e.printStackTrace();
}
return i;
}



//定义了管理员的信息类
package entity;

public class usermessge {
private String name;
private String nation;
private String bridays;
private String idcard;
private String address;
private int phone;
private int tel;
private String emil;
private String belong;
private int code;
private String nowadress;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNation() {
return nation;
}
public void setNation(String nation) {
this.nation = nation;
}

public String getBridays() {
return bridays;
}
public void setBridays(String bridays) {
this.bridays = bridays;
}
public String getIdcard() {
return idcard;
}
public void setIdcard(String idcard) {
this.idcard = idcard;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getPhone() {
return phone;
}
public void setPhone(int phone) {
this.phone = phone;
}
public int getTel() {
return tel;
}
public void setTel(int tel) {
this.tel = tel;
}
public String getEmil() {
return emil;
}
public void setEmil(String emil) {
this.emil = emil;
}
public String getBelong() {
return belong;
}
public void setBelong(String belong) {
this.belong = belong;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getNowadress() {
return nowadress;
}
public void setNowadress(String nowadress) {
this.nowadress = nowadress;
}

}

//控制器
package Contorl;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLEncoder;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.Model;

public class usermessgeServelt extends HttpServlet {

/**
*
*/
private static final long serialVersionUID = 1L;

/**
* Constructor of the object.
*/
public usermessgeServelt() {
super();
}

/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String name=request.getParameter("name");
String nation=request.getParameter("nation");
String bridays=request.getParameter("bridays");
String idcard=request.getParameter("idcard");
int phone=Integer.parseInt(request.getParameter("phone"));
String address=request.getParameter("address");
int tel=Integer.parseInt(request.getParameter("tel"));
String emil=request.getParameter("emil");
String belong=request.getParameter("belong");
int code=Integer.parseInt(request.getParameter("code"));
String nowadress=request.getParameter("nowadress");
Model model=new Model();
int i=model.usermessgeupdate(name, nation, bridays, idcard, address, phone, tel, emil, belong, code, nowadress);
if(i==1){
PrintWriter out=response.getWriter();
String a = URLEncoder.encode("完成修改", "UTF-8");
out.print("<script language='javascript'>alert(decodeURIComponent('"+a+"'));window.location.href=('UserMessge.jsp');</script>");
}
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(req, resp);

}

/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}

}

为什么总是没有这个字段啊!!!!!!求大神解决 急急急!!!!!!!!
...全文
2422 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ChuJuANdJL 2020-12-22
  • 打赏
  • 举报
回复
如果数据库中有乱码怎么办
墨笙弘一 2018-05-04
  • 打赏
  • 举报
回复
找不到字段,看看你的字段是否和数据库字段一致,如果一致看看你的数据库中是否存在乱码,如果不存在乱码,你可以尝试直接用sql insert 看看效果,如果可以成功,说明表没有问题,那就是你程序问题了
self_defining 2018-05-04
  • 打赏
  • 举报
回复
就是表中的字段和查询时写的字段不一致的吧
亲爱的Joe 2018-05-04
  • 打赏
  • 举报
回复
你的studb表没有nation字段吧。你发的图是studb表的截图么
masteryourself 2018-05-04
  • 打赏
  • 举报
回复
楼主先把nation打印一下看看是什么值,然后再放到数据库里执行这条sql 看看是否报错
诺丽果 2018-05-04
  • 打赏
  • 举报
回复
你的前台页面上有这个字段吗?报的错误信息里面是at Contorl.usermessgeServelt.doPost(usermessgeServelt.java:59),你debug看看,是不是到usermessgeServelt.doPost的59行报错的,很可能你前台页面没有这个字段,所以String nation=request.getParameter("nation");取不到
QWERT4745 2018-05-04
  • 打赏
  • 举报
回复
把sql直接放到数据库执行试下,再看下建表的时候这些字段后面是不是多了空格啥的
qq_41924365 2018-05-04
  • 打赏
  • 举报
回复
我的数据库的表连接错 问题已经解决了。
qq_41924365 2018-05-03
  • 打赏
  • 举报
回复

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧