此类问题一般由两个原因,
1、循环过程中关闭了rs
解决此问题,只要将关闭连接放到循环外即可。
2、循环中的其他操作也会关闭rs,例如:
DB_function_bean dfb = new DB_function_bean();
String sql = "select ID from t_notice";
ResultSet rs = dfb.executeQuery(sql1);
while(rs.next())
{
String N_ID = rs2.getString(1);
String sql2 = "insert into t_user_notice(USER_ID,NOTICE_ID) VALUES('"+U_ID+"','"+N_ID+"')";
dfb.execute(sql2);
}
执行dfb.execute(sql2)会关闭rs,解决办法是用一个新的连接执行execute(sql2),即:
DB_function_bean dfb = new DB_function_bean();
DB_function_bean dfb1 = new DB_function_bean();
String sql = "select ID from t_notice";
ResultSet rs = dfb.executeQuery(sql1);
while(rs.next())
{
String N_ID = rs2.getString(1);
String sql2 = "insert into t_user_notice(USER_ID,NOTICE_ID) VALUES('"+U_ID+"','"+N_ID+"')";
dfb1.execute(sql2);
}
分享到:
相关推荐
解决:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.
使用mysql+cp30连接池时,报错No operations allowed after connection closed。从报错信息来看,是connection断开导致的错误。在网上搜索后发现,较新版本的mysql配置了connection的默认时间,默认时间一般为8个...
java.sql.SQLException: Operation not allowed after ResultSet closed java.sql.SQLException: QueryRunner requires a DataSource to be invoked in this way, or a Connection should be passed in
主要介绍了php采用curl访问域名返回405 method not allowed提示的解决方法,需要的朋友可以参考下
Android WebView 报 Not allowed to load local resource错误的解决办法 博客地址:http://blog.csdn.net/yuzhiqiang_1993/article/details/76228541
设置隐试打开PPT报错 Hiding the application window is not allowed
NR5G网络拒绝码-5gmm_cause = 7 (0x7) (5GS Service not allowed)
Host 主机名 is not allowed to connect the mysql server 原因:没有授权远程访问mysql 解决方法: cmd 中运行mysql -u root -p(如果报mysql 不是内部或外部命令,找到安装mysql对应的bin文件夹运行mysql.exe,...
从3GPP协议和UE端行为分析5G gmm cause #27的网络问题
"Host 'localhost' is not allowed to connect to this MySQL server" 的原因及解决办法
主要介绍了http请求405错误方法不被允许的解决 (Method not allowed),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
Origin 'null' is therefore not allowed access. 这就是跨域问题。解决方案有不少,比较好的是服务器端配置CORS,但要求服务器端做更改。如果在不需要更改服务器端的情况下解决呢?尤其是需要在
NULL 博文链接:https://yizhilong28.iteye.com/blog/1137285
nginx: [emerg] “proxy_cache_path” directive is not allowed here in /etc/nginx/conf.d/default.conf:29 提示意思“proxy_cache_path指令不被允许”,在官网上查找了相关说明,也没有发现问题,最后看应用范围...
主要给大家介绍了关于Golang报"import cycle not allowed"错误的2种解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以们下面随着小编来一起看看吧
message from server: “Host ‘****’ is not allowed to connect to this MySQL server 1:在登录mysql服务器 2:执行:GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ WITH GRANT OPTION //赋予任何主机访问数据的...
主要给大家介绍了关于golang中不允许循环import问题("import cycle not allowed")的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考借鉴,下面随着小编来一起学习学习吧
RTSP协议分析 rtp_over_rtsp精简分析 rfc2326(RTSP) 详细文档说明 RTSP协议资料 几个文档资料比较全
NULL 博文链接:https://rayoo.iteye.com/blog/1973032
如果你想连接你的mysql的时候发生这个错误: 代码如下: ERROR 1130: Host ‘192.168.1.3’ is not allowed to connect to this MySQL server 解决方法: 1。 改表法。可能是你的帐号不允许从远程登陆,只能在...