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

这是怎么回事?

2013-09-11 
这是咋回事?????在下初学jsp,大家帮帮忙~~代码:Statementstmtupconn.createStatement()StringSqlu upd

这是咋回事?????
在下初学jsp,大家帮帮忙~~
代码:
Statement   stmtup=conn.createStatement();
String   Sqlu= "update   tArticle   set   fTitle= ' "+Title+ " ',fClassID= ' "+ClassID+ " ',fAuthor= ' "+Author+ " ',fCopyFrom= ' "+   CopyFrom+ " ',fKey= ' "+Key+ " ',fContent= ' "+Content+ " ',fIncludePic= ' "+   IncludePic+ " ',fDefaultPicUrl= ' "+DefaultPicUrl+ " ',fSavePicPathFileName= ' "+   SavePicPathFileName   + " '   where   fArticleID= "+ID;

int   gai   =   stmtup.executeUpdate(Sqlu);
if   (gai> 0)
{
out.print( " <p   align= 'center '> 文章修更改成功 </p> ");
}
错误提示:
HTTP   Status   500   -  

--------------------------------------------

type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   An   exception   occurred   processing   JSP   page   /www/Admin/Article_Update.jsp   at   line   96

93:   Statement   stmtup=conn.createStatement();
94:   String   Sqlu= "update   tArticle   set   fTitle= ' "+Title+ " ',fClassID= ' "+ClassID+ " ',fAuthor= ' "+Author+ " ',fCopyFrom= ' "+   CopyFrom+ " ',fKey= ' "+Key+ " ',fContent= ' "+Content+ " ',fIncludePic= ' "+   IncludePic+ " ',fDefaultPicUrl= ' "+DefaultPicUrl+ " ',fSavePicPathFileName= ' "+   SavePicPathFileName   + " '   where   fArticleID= "+ID;
95:  
96:   double   gai   =   stmtup.executeUpdate(Sqlu);
97:   if   (gai> 0)
98:   {
99:   out.print( " <p   align= 'center '> 文章修更改成功 </p> ");


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root   cause  

javax.servlet.ServletException:   java.sql.SQLException:   [Microsoft][ODBC   Microsoft   Access   Driver]   标准表达式中数据类型不匹配。
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.www.Admin.Article_005fUpdate_jsp._jspService(Article_005fUpdate_jsp.java:358)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


root   cause  

java.sql.SQLException:   [Microsoft][ODBC   Microsoft   Access   Driver]   标准表达式中数据类型不匹配。


sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown   Source)
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown   Source)
sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown   Source)
sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown   Source)
sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Unknown   Source)
org.apache.jsp.www.Admin.Article_005fUpdate_jsp._jspService(Article_005fUpdate_jsp.java:204)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)



[解决办法]
out.println(sql);
[解决办法]
sql有问题,数据类型跟数据库不一致.
[解决办法]
你把数据跟数据库里的类型对比一下,有类型不一致的,把它找出来.
把sql打印出来,一个个对比.
[解决办法]
上面的问题相信楼主已经解决了吧,在这里提个建议,你的那个sql语句也是有些复杂,对以后的修改不利,String Sqlu= "update tArticle set fTitle= ' "+Title+ " ',fClassID= ' "+ClassID+ " ',fAuthor= ' "+Author+ " ',fCopyFrom= ' "+ CopyFrom+ " ',fKey= ' "+Key+ " ',fContent= ' "+Content+ " ',fIncludePic= ' "+ IncludePic+ " ',fDefaultPicUrl= ' "+DefaultPicUrl+ " ',fSavePicPathFileName= ' "+ SavePicPathFileName + " ' where fArticleID= "+ID;
我是用PreparedStatement,
PreparedStatement pst;
String sql= "update lamp set type=?,intro=?,picture=? where id=? ";
pst=conn.prepareStatement(sql);
pst.setString(1,item.getType());
pst.setString(2, item.getIntro());
pst.setString(3, item.getPicture());
pst.setInt(4,item.getID());
pst.executeUpdate();
不知道楼主会不会用BEAN,这样修改起来会方便不少。
我的异常网推荐解决方案:An exception occurred processing JSP page,http://www.myexception.cn/j2se/33144.html
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html

热点排行