标题:CachedRowSet问题
只看楼主
zhanglinkai
Rank: 1
等 级:新手上路
帖 子:87
专家分:0
注 册:2006-11-25
 问题点数:0 回复次数:1 
CachedRowSet问题

<% 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)

请大家帮忙指教一下是什么问题 谢谢!!

搜索更多相关主题的帖子: CachedRowSet 
2007-07-30 08:03
zhanglinkai
Rank: 1
等 级:新手上路
帖 子:87
专家分:0
注 册:2006-11-25
得分:0 

还有个问题,我在使用Visual web pack 时使用上面的语句根本插不进去值 我在一个BUTTON事件监听里写了下面代码
public String button1_action(){
// 待做事项:处理按钮单击操作。返回的值是一个导航
// 条件名称,如果它为 Null,则返回到同一页。

try{
CachedRowSetXImpl chrs=getSessionBean1().getUserRowSet();
chrs.execute();
chrs.moveToInsertRow();
chrs.updateInt(1,9);
chrs.updateString(2,"666nih55aorr");
chrs.updateString(3,"850542443");
chrs.insertRow();
chrs.moveToCurrentRow();
chrs.acceptChanges();
}
catch(Exception e){
error(e.getMessage());
}

return null;
}
执行后提示
提示表中没有列:user请大家指教!!!


希望自己能走的更远!!!
2007-07-30 08:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-159063-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.662045 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved