首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JSP修改数据库信息调试老是提示String literal is not properly closed by a double-quote解决办法

2012-02-01 
JSP修改数据库信息调试老是提示String literal is not properly closed by a double-quote我的代码是这样

JSP修改数据库信息调试老是提示String literal is not properly closed by a double-quote
我的代码是这样的 各位前辈请耐心一下帮我看看 我真的调了很久都调不好 就是那句UPDATE 的参数 帮我看看拉 万分感谢!
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改记录</title>
<body>
<%! String xuehao,name,sex,age,school,grade,classes,minzu,mianmao,marrage,zhicheng,xuexing,
  phone,s_address,f_address,youzheng,email,guojia,jiguan,hukou,mainpage,qqnumber,teacher,url,sqlString; %>
<%! int i;%>
<%! Connection conn;//定义数据库连接对象 %>
<%! Statement stmt;//定义SQL语句对象 %>
<%
 xuehao=request.getParameter("xuehao").trim();
name=request.getParameter("name").trim();
name=new String(name.getBytes("ISO-8859-1"));
  sex=request.getParameter("sex").trim();
  sex=new String(sex.getBytes("ISO-8859-1"));
  age=request.getParameter("age").trim();
  i=Integer.parseInt(age);
  school=request.getParameter("school").trim();
  school=new String(school.getBytes("ISO-8859-1"));
  grade=request.getParameter("grade").trim();
  grade=new String(grade.getBytes("ISO-8859-1"));
  classes=request.getParameter("classes").trim();
  classes=new String(classes.getBytes("ISO-8859-1"));
  minzu=request.getParameter("minzu").trim();
  minzu=new String(minzu.getBytes("ISO-8859-1"));
  mianmao=request.getParameter("mianmao").trim();
  mianmao=new String(mianmao.getBytes("ISO-8859-1"));
  marrage=request.getParameter("marrage").trim();
  marrage=new String(marrage.getBytes("ISO-8859-1"));
  zhicheng=request.getParameter("zhicheng").trim();
  zhicheng=new String(zhicheng.getBytes("ISO-8859-1"));
  xuexing=request.getParameter("xuexing").trim();
  xuexing=new String(xuexing.getBytes("ISO-8859-1"));
  phone=request.getParameter("phone").trim();
  phone=new String(phone.getBytes("ISO-8859-1"));
  s_address=request.getParameter("s_address").trim();
  s_address=new String(s_address.getBytes("ISO-8859-1"));
  f_address=request.getParameter("f_address").trim();
  f_address=new String(f_address.getBytes("ISO-8859-1"));
  youzheng=request.getParameter("youzheng").trim();
  youzheng=new String(youzheng.getBytes("ISO-8859-1"));
  email=request.getParameter("email").trim();
  email=new String(email.getBytes("ISO-8859-1"));
  guojia=request.getParameter("guojia").trim();
  guojia=new String(guojia.getBytes("ISO-8859-1"));
  jiguan=request.getParameter("jiguan").trim();
  jiguan=new String(jiguan.getBytes("ISO-8859-1"));
  hukou=request.getParameter("hukou").trim();
  hukou=new String(hukou.getBytes("ISO-8859-1"));
  mainpage=request.getParameter("mainpage").trim();
  mainpage=new String(mainpage.getBytes("ISO-8859-1"));
  qqnumber=request.getParameter("grade").trim();
  qqnumber=new String(qqnumber.getBytes("ISO-8859-1"));
  teacher=request.getParameter("teacher").trim();
  teacher=new String(teacher.getBytes("ISO-8859-1"));
if(name.equals("")){
  response.sendRedirect("err.jsp");


  }
try{ 
  Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
   
  url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=master";
conn=DriverManager.getConnection(url,"sa","02051306");//建立与数据库的连接
stmt=conn.createStatement();
sqlString="update student set name='"+name+"',sex='"+sex+"',age='"+i+"',school='"+school+"',grade='"+grade+"',classes='"+classes+"',minzu='"+minzu+"',mianmao='"+mianmao+"',marrage='"+marrage+"',zhicheng='"+zhicheng+"',xuexing='"+xuexing+"',phone='"+phone+"',s_address='"+s_address+"',f_address='"+f_address+"',youzheng='"+youzheng+"',email='"+email+"',guojia='"+guojia+"',jiguan='"+jiguan+"',hukou='"+hukou+"',mainpage='"+mainpage+"',qqnumber='"+qqnumber+"',teacher='"+teacher+"' where xuehao=
'"+xuehao+"'";
stmt.executeUpdate(sqlString);
out.println("<font size=3 color=blue>异常异常!!");
out.println("<font size=3 color=blue>正在修改记录,请稍后......</font><meta http-equiv='refresh' content='2;url=jbxx.jsp'>");
stmt.close();
conn.close();
  }
  catch(Exception e){
out.println("错误!");
}
%>
</body>

[解决办法]
你在不应该换行的地方换行了,复制过去,替换你的那2行!

Java code
sqlString="update  student  set name='"+name+"',sex='"+sex+"',age='"+i+"',school='"+school+"',grade='"+grade+"',classes='"+classes+"',minzu='"+minzu+"',mianmao='"+mianmao+"',marrage='"+marrage+"',zhicheng='"+zhicheng+"',xuexing='"+xuexing+"',phone='"+phone+"',s_address='"+s_address+"',f_address='"+f_address+"',youzheng='"+youzheng+"',email='"+email+"',guojia='"+guojia+"',jiguan='"+jiguan+"',hukou='"+hukou+"',mainpage='"+mainpage+"',qqnumber='"+qqnumber+"',teacher='"+teacher+"' where xuehao='"+xuehao+"'"; 

热点排行