当前位置: 技术问答>java相关
没有高定,大家在看看!!最后5分,别嫌少
来源: 互联网 发布时间:2015-01-24
本文导语: String name=request.getParameter("na"); String zt=request.getParameter("zt"); String nr=request.getParameter("nr"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:test","sa",""); Statement s=con.createStatement(1004,1007) ; S...
String name=request.getParameter("na");
String zt=request.getParameter("zt");
String nr=request.getParameter("nr");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:test","sa","");
Statement s=con.createStatement(1004,1007) ;
String sql="insert into article (zz,nr,tm) values ('"+name+"','"+zt+"','"+nr+"')";
//response.sendRedirect("www.sohu.com");
ResultSet rs=s.executeQuery(sql);
//ResultSet rs=s.executeQuery("select * from article");
rs.close() ;
con.close() ;
s.close() ;
错误提示:javax.servlet.ServletException: No ResultSet was produced
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
at _0002finsert_00031_0002ejspinsert1_jsp_11._jspService(_0002finsert_00031_0002ejspinsert1_jsp_11.java:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
字段顺序改过了,rs.executeupdate(sql)也试过了,虽然可以插入数据库,但是有以上出错信息
String zt=request.getParameter("zt");
String nr=request.getParameter("nr");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:test","sa","");
Statement s=con.createStatement(1004,1007) ;
String sql="insert into article (zz,nr,tm) values ('"+name+"','"+zt+"','"+nr+"')";
//response.sendRedirect("www.sohu.com");
ResultSet rs=s.executeQuery(sql);
//ResultSet rs=s.executeQuery("select * from article");
rs.close() ;
con.close() ;
s.close() ;
错误提示:javax.servlet.ServletException: No ResultSet was produced
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
at _0002finsert_00031_0002ejspinsert1_jsp_11._jspService(_0002finsert_00031_0002ejspinsert1_jsp_11.java:85)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
字段顺序改过了,rs.executeupdate(sql)也试过了,虽然可以插入数据库,但是有以上出错信息
|
对于Insert,应该用s.executeUpdate()
对select,用s.executeQuery()
对select,用s.executeQuery()
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。