<% Class.forName("com.mysql.jdbc.Driver");
CachedRowSetImpl chrs=new CachedRowSetImpl();
chrs.setUrl("jdbc:mysql://localhost:3306/testdb");
chrs.setUsername("root");
chrs.setPassword("850423");
//chrs.setDataSourceName("java:comp/evn/jdbc/testdb");
chrs.setCommand("SELECT * FROM user");
chrs.execute();
chrs.moveToInsertRow();
chrs.updateInt(1,7);
chrs.updateString(2,"nihorr");
chrs.updateString(3,"hh");
chrs.insertRow();
chrs.moveToCurrentRow();
chrs.acceptChanges();
%>
我写这些语句练习数据库插入,每次数据能插进去,但是还提示错误
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
root cause
javax.servlet.ServletException: Can't call commit when autocommit=true
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.index_jsp._jspService(index_jsp.java:90)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
root cause
javax.sql.rowset.spi.SyncProviderException: Can't call commit when autocommit=true
com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:858)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
请大家帮忙指教一下是什么问题 谢谢!!