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

JSP表单信息输入数据库的有关问题

2013-09-11 
JSP表单信息输入数据库的问题.代码为:%Stringnumrequest.getParameter( num )Stringtypeidrequest.g

JSP表单信息输入数据库的问题.
代码为:
<%   String   num=request.getParameter( "num ");
      String   typeid=request.getParameter( "typeid ");
      String   seno=request.getParameter( "seno ");
      String   eno=request.getParameter( "eno ");
      String   wdate=request.getParameter( "wdate ");
      String   ano=request.getParameter( "ano ");
String   sql= "insert   into   pageinfo(num,typeid,seno,eno,wdate,ano)    
values( ' "+num+ " ', ' "+typeid+ " ', ' "+seno+ " ', ' "+eno+ " ', ' "+wdate+ " ', ' "+ano+ " ')   ";
    addx.executeUpdate(sql);
try{     sqlBean   db   =new   sqlBean();  
                        db.executeUpdate(sql);
                    }  
                catch(Exception   e){System.out.print(e.toString());}
    out.println( "ok ");
    response.sendRedirect( "fu.jsp ");
  %>
错误为
org.apache.jasper.JasperException:   Unable   to   compile   class   for   JSP:  

An   error   occurred   at   line:   16   in   the   jsp   file:   /biyesheji/nixie/addx.jsp
String   literal   is   not   properly   closed   by   a   double-quote
13:         String   eno=request.getParameter( "eno ");
14:         String   wdate=request.getParameter( "wdate ");
15:         String   ano=request.getParameter( "ano ");
16:   String   sql= "insert   into   pageinfo(num,typeid,seno,eno,wdate,ano)    
17:   values( ' "+num+ " ', ' "+typeid+ " ', ' "+seno+ " ', ' "+eno+ " ', ' "+wdate+ " ', ' "+ano+ " ')   ";
18:       addx.executeUpdate(sql);
19:   try{     sqlBean   db   =new   sqlBean();  


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:298)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:299)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


求助高手帮忙

[解决办法]
是不是类型不对啊 如果数据库中num是int型的 那么用 ' '把它括起来肯定是错的
[解决办法]
一行代码可以换行写,一个String的内容是不能换几行写的,写成
String sql= "insert into pageinfo(num,typeid,seno,eno,wdate,ano) " +


"values( ' "+num+ " ', ' "+typeid+ " ', ' "+seno+ " ', ' "+eno+ " ', ' "+wdate+ " ', ' "+ano+ " ') ";
[解决办法]
估计是数据库表的字段类型,跟你写的SQL语句不符合,肯定有number类型的,
再组织sql语句的时候不用加 ' '
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html

热点排行