no operations allowed after connection closed

数据库连接配置

<!-- 配置MyBatis3的环境 -->
<environments default="env">
    <!-- 配置一个环境 -->
    <environment id="env">
        <!-- 配置事务管理器 JDBC(有事务)、MANAGED(托管) -->
        <transactionManager type="JDBC" />
        <!-- 配置数据源 JNDI(web服务器方式定义数据源)、POOLED(自带连接池)、UNPOOLED(不带连接池) -->
        <dataSource type="POOLED">
            <!-- 连接数据库驱动 -->
            <property name="driver" value="com.mysql.jdbc.Driver" />
            <!-- 连接数据库URL -->
            <property name="url" value="jdbc:mysql:///wkmj_wechat?useUnicode=true&amp;characterEncoding=UTF-8&amp;zeroDateTimeBehavior=convertToNull" />
            <!-- 连接数据库用户名 -->
            <property name="username" value="root" />
            <!-- 连接数据库密码 -->
            <property name="password" value="root" />
        </dataSource>
    </environment>
</environments>

JAVA代码

/**

  • 获取SqlSession和关闭SqlSession的基础类
  • @author Administrator * */

public class BaseDao {
private static SqlSessionFactory factory;
/**
* 线程对象
/
private static ThreadLocal threadLocal = new ThreadLocal<>();
/
*通过静态块初始化SqlSessionFactory,因为静态块只会在类第一次加载的时候执行*/
static {
try(InputStream in = Resources.getResourceAsStream("mybatis_config.xml");) {
factory = new SqlSessionFactoryBuilder().build(in);
} catch (IOException e) {
e.printStackTrace();
System.err.println("数据库连接工厂获取失败!");
}
}
/**
* 获取SqlSession对象
* @return SqlSession
*/
public static SqlSession getSqlSession(){
//通过ThreadLocal获取sqlSession对象
//第二次进来的时候就可以从threadLocal.get()中获取
SqlSession sqlSession = threadLocal.get();

    if(sqlSession == null){
        //获取一个SqlSession对象
        sqlSession = factory.openSession();
        //并存储到ThreadLocal对象中,通过ThreadLocal对象可以方便进行线程同步管理
        //前程同步交给工具管理
        threadLocal.set(sqlSession);
    }
    return sqlSession;
}
/**
 * 关闭SqlSession对象
 */
public static void closeSqlSession(){
    SqlSession sqlSession = threadLocal.get();
    if(sqlSession != null){
        sqlSession.close();
    }
    threadLocal.remove();
}

}

发布到服务器后每隔几次点击就会有no operations allowed after connection closed报错,但是本地测试没有这个情况出现

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
no operations allowed after statement closed
最近做了一个SWING的程序,我希望通过程序来操作一个终端,比如用读卡器来读IC卡,就好像我们上班打卡的那样,程序我写出来了,也可以使用,但是有时候在打卡的时候会报错rn如下:[color=#FF0000]no operations allowed after statement closed[/color]rnrn好像是说数据库操作对象被关闭了,但是在程序当中我并没有关闭statement对象,而且这个错误不是总出来,而是时有时无,每次都需要重启程序或者重启系统才能正常!rnrn补充:我用的是mysql的数据库rnrn请各位帮忙解决一下,谢谢了!!!
No operations allowed after statement closed
[code=java]21:01:11,919 WARN org.hibernate.jdbc.AbstractBatcher:302 - exception clearing maxRows/queryTimeoutrncom.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)rn at com.mysql.jdbc.Util.getInstance(Util.java:386)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)rn at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:461)rn at com.mysql.jdbc.StatementImpl.getMaxRows(StatementImpl.java:2216)rn at org.apache.commons.dbcp.DelegatingStatement.getMaxRows(DelegatingStatement.java:237)rn at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:298)rn at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)rn at org.hibernate.loader.Loader.getResultSet(Loader.java:1967)rn at org.hibernate.loader.Loader.doQuery(Loader.java:802)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)rn at org.hibernate.loader.Loader.doList(Loader.java:2542)rn at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)rn at org.hibernate.loader.Loader.list(Loader.java:2271)rn at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459)rn at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365)rn at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)rn at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)rn at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)rn at com.jmy.logic.JEssayLogic.find(JEssayLogic.java:167)rn at com.jmy.service.impl.JEManagerImpl.find(JEManagerImpl.java:47)rn at com.jmy.action.JmyOnePage.loadPage(JmyOnePage.java:47)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:292)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:255)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)rn at org.apache.catalina.core.StandardWrapperValve.invrnrn配置文件是[code=html]rn rn rn rn com.wds.registration.modelrn com.jmy.essay.modelrn com.jmy.picture.modelrn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn truern updatern truern truern truern truern rn rn rn rn [/code]rnjava调用代码[code=java]public List find(List e_EMLs) rn /** select title,author from List(table'name) order by id desc LIMIT 8 **/rn List tbes = new ArrayList();rn tbes.clear();rn tbes.add("E_Rcm");rn tbes.add("E_Egh");rn tbes.add("E_Mword");rn tbes.add("E_Bword");rn tbes.add("E_Fas");rn tbes.add("E_Clas");rnrn e_EMLs = new ArrayList();rn String sql1 = "select id,title,author,rlTime,tbName from ";rn String sql2 = " order by id desc";rn int stNO = 0, elNO = 8;rn Session session = sessionFactory.openSession();rn for (int i = 0; i < tbes.size(); i++) rn List<_essay_Model> e_Ml = new ArrayList<_essay_Model>();rn E_EML e_EML = new E_EML();rnrn Query query = session.createQuery(sql1 + tbes.get(i) + sql2);rn query.setFirstResult(stNO);rn query.setMaxResults(elNO);rn List l = query.list();rnrn for (int j = 0; j < l.size(); j++) rn Object[] objs = (Object[]) l.get(j);rn _essay_Model em = new _essay_Model();rn em.setId((Integer) objs[0]);rn em.setTitle((String) objs[1]);rn em.setAuthor((String) objs[2]);rn DateFormat dformat = new SimpleDateFormat("yyyy-MM-dd");rn em.setRltoStr(dformat.format((Timestamp) objs[3]));rn em.setTbName((String) objs[4]);rn e_Ml.add(em);rn rn e_EML.setE_Ms(e_Ml);rn e_EMLs.add(e_EML);rn rn rn session.close();rn sessionFactory.close();rn return e_EMLs;rn rn[/code]
关于JDBC中No operations allowed after connection closed的问题
rn[code=Java]public static Operater check(String name, String password) rn Operater operater=new Operater();//操作员信息对象rn String sql = "select * from tb_operator where name='" + namern + "' and password='" + password + "'and admin=1";//查询字符串rn ResultSet rs = Dao.executeQuery(sql);//执行查询rn try rn while (rs.next()) //如果查询到了记录rn operater.setId(rs.getString("id"));//设置操作员编号rn operater.setName(rs.getString("name"));//设置操作员用户名rn operater.setGrade(rs.getString("admin"));//设置操作员等级rn operater.setPassword(rs.getString("password"));//设置管理员密码rn rn catch (Exception e) rn e.printStackTrace();rn rn Dao.close(); //关闭连接对象rn return operater;//返回操作员信息对象rn [/code]rnrn第一次调用此方法没问题 可第二次就出现下面的问题rnrncom.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: rnNo operations allowed after connection closedrnrn这个问题怎么解决啊 只有把Dao.close();这个关闭Connection的方法去掉,可是这样好像也不对啊?rn各位有没有碰到过类似的问题,有好的解决办法?
TOMCAT配置MYSQL连接池出现No operations allowed after connection closed
在TOMCAT4里配置MYSQL连接池后,系统持续运行不会出现问题,但如果几分钟没操作就会出现No operations allowed after connection closed异常。rn我仔细检查过URL,已经设置了autoReconnect=true,maxWait也设为-1(无限时等待)。rn请问为什么会出现这种错误?有什么要注意吗?rn谢谢
求助:MYSQL出错:java.sql.SQLException: No operations allowed after connection closed
web应用平台是apache2.51 + tomcat4.1.30 ,采用mysql数据库,都在一台机器上,在并发100以下用户时不会出现任何问题,但在做5次100并发测试时,tomcat控制台报错rnrnjava.sql.SQLException: No operations allowed after connection closedrnrn进入mysql时发现rnMax_used_connections | 90 rn而mysql的最大连接数据是500,远远高于90,rnshow processlist;也只有50左右rn数据库的连接池的大小是400,rnrnshow status;状态如下:rn| Max_used_connections | 90 |rn| Not_flushed_key_blocks | 0 |rn| Not_flushed_delayed_rows | 0 |rn| Open_tables | 142 |rn| Open_files | 170 |rn| Open_streams | 0 |rn| Opened_tables | 148 |rn| Questions | 212930 |rn| Qcache_queries_in_cache | 1083 |rn| Qcache_inserts | 31126 |rn| Qcache_hits | 135176 |rn| Qcache_lowmem_prunes | 0 |rn| Qcache_not_cached | 1391 |rn| Qcache_free_memory | 15118992 |rn| Qcache_free_blocks | 319 |rn| Qcache_total_blocks | 2523 |rn| Rpl_status | NULL |rn| Select_full_join | 33886 |rn| Select_full_range_join | 0 |rn| Select_range | 13714 |rn| Select_range_check | 0 |rn| Select_scan | 3236 |rn| Slave_open_temp_tables | 0 |rn| Slave_running | OFF |rn| Slow_launch_threads | 0 |rn| Slow_queries | 1 |rn| Sort_merge_passes | 0 |rn| Sort_range | 9654 |rn| Sort_rows | 239147 |rn| Sort_scan | 8136 |rn| Table_locks_immediate | 98411 |rn| Table_locks_waited | 549 |rn| Threads_cached | 2 |rn| Threads_created | 7428 |rn| Threads_connected | 53 |rn| Threads_running | 1 |rn| Uptime | 4294855340 |rnrn rnrn谁能告诉我是哪出了问题撒,在此谢过了......
TOMCAT配置MYSQL连接池,出现No operations allowed after connection closed
在TOMCAT4里配置MYSQL连接池后,系统持续运行不会出现问题,但如果几分钟没操作就会出现No operations allowed after connection closed异常。rn我仔细检查过URL,已经设置了autoReconnect=true,maxWait也设为-1(无限时等待)。rn请问为什么会出现这种错误?有什么要注意吗?rn谢谢
在写servlet时连接数据库出现No operations allowed after connection closed
我在做上传图片到服务器然后数据库存这个图片的地址,下面name是传递过来的图片的地址,第一次能正确存进去,后面再也存不进去,并出现题目的错误rn[code=java]rnpackage uploadPack;rnrnimport java.sql.Connection;rnimport java.sql.PreparedStatement;rnimport java.sql.ResultSet;rnrnpublic class ItemManager rn public void uploadItemImage(String itemNo,String name)rn Connection conn=null;rn PreparedStatement stmt=null;rn ResultSet rs=null;rn tryrn conn=DBHelper.getConnection();rn stmt=conn.prepareStatement("INSERT pictures(picture) VALUES(?)");rn stmt.setString(1, name);rn stmt.executeUpdate();rn catch (Exception ex) rn ex.printStackTrace();rn finally rn DBHelper.close(rs, stmt, conn);rn rn rnrn[/code]rn下面是加载和创建数据库的类rn[code=java]rnpackage uploadPack;rnrnimport java.sql.Connection;rnimport java.sql.DriverManager;rnimport java.sql.ResultSet;rnimport java.sql.Statement;rnrnpublic class DBHelper rn rn //静态代码块来加载驱动rn static rn tryrn String driverName="com.mysql.jdbc.Driver";rn Class.forName(driverName);rn catch(Exception e)rn e.printStackTrace();//打印异常输出rn rn rn rn //连接到指定的数据库,三个参数分别是数据库地址,账号,密码rn public static Connection getConnection()rn Connection conn=null;rn tryrn conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/Demos", "root", "root");rn catch(Exception e)rn e.printStackTrace();rn rn return conn;rn rn rn //关闭数据库连接rn public static void close(ResultSet rs,Statement stmt,Connection conn)rn tryrn if(rs!=null)rn rs.close();rn catch(Exception ex)rn ex.printStackTrace();rn rn rn tryrn if(stmt!=null)rn stmt.close();rn catch(Exception ex)rn ex.printStackTrace();rn rn rn tryrn if(conn!=null)rn conn.close();rn catch(Exception ex)rn ex.printStackTrace();rn rn rnrn[/code]rnrn这个问题我在CSDN上看到原因,但不理解,我想知道我这个怎么改~
java.sql.SQLException: No operations allowed after connection closed.
package com.guikai.chenli;rnrnimport java.sql.*;rnimport com.mysql.jdbc.Driver;rnrnpublic class Conn rn Connection connection=null;rn public Conn()rn try rn Class.forName("com.mysql.jdbc.Driver").newInstance();rn catch (InstantiationException e) rn e.printStackTrace();rn catch (IllegalAccessException e) rn e.printStackTrace();rn catch (ClassNotFoundException e) rn e.printStackTrace();rn rn// String serverIP="121.199.28.34";rn// String dbName="zkh0y1_db";rn// String userName="zkh0y1";rn// String userPasswd="s8i2r7j8";rnrn String serverIP="127.0.0.1";rn String dbName="renda";rn String userName="root";rn String userPasswd="111111";rnrn try rn connection=DriverManager.getConnection("jdbc:mysql://"+serverIP+"/"+dbName+"?autoReconnect=true",userName,userPasswd);rn catch (SQLException e) rn //System.out.println("----------");rn e.printStackTrace();rn rn rn rn rn public void close()rn if(connection!=null)rn try rn connection.close();rn catch (SQLException e) rn e.printStackTrace();rn rn rnrn public void exe(String sql)rn Statement stmt=null;rn try rn stmt = connection.createStatement();rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn try rn stmt.executeUpdate(sql);rn catch (SQLException e) rn e.printStackTrace();rn rn try rn if(stmt!=null)rn stmt.close();rn catch (SQLException e) rn e.printStackTrace();rn rn rnrn public ResultSet query(String sql)rn Statement stmt=null;rn ResultSet rs=null;rn try rn stmt = connection.createStatement();rn catch (SQLException e) rn e.printStackTrace();rn rn try rn rs=stmt.executeQuery(sql);rn catch (SQLException e) rn e.printStackTrace();rn rn return rs;rn rnrnrnrnrnrn老出现java.sql.SQLException: No operations allowed after connection closed.错误,谁知道怎么解决
No operations allowed after statement closed.
解决:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.
Spring hibernate mysql No operations allowed after statement closed
sessionFactory spring中配置的sessionfactory代码 [code=text]rn rn rn rn com.wds.registration.modelrn com.jmy.essay.modelrn com.jmy.picture.modelrn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn truern updatern rn rn rn[/code]rn后台有个调用[code=java] public class JEssayLogic rn rn private SessionFactory sessionFactory;rnrn rn public E_ML find(E_ML e_ML) rn rn Session session = sessionFactory.openSession();rn rn Query query = session.createQuery("SQL...................");rn rn List l = query.list();rn rn session.close();rn sessionFactory.close();rn return e_ML;rn rnrn rn [/code] 但是web程序连接长了 程序就会报[code=text]com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after statement closed.rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)rn at java.lang.reflect.Constructor.newInstance(Constructor.java:513)rn at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)rn at com.mysql.jdbc.Util.getInstance(Util.java:386)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)rn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)rn at com.mysql.jdbc.StatementImpl.checkClosed(StatementImpl.java:461)rn at com.mysql.jdbc.StatementImpl.getMaxRows(StatementImpl.java:2216)rn at org.apache.commons.dbcp.DelegatingStatement.getMaxRows(DelegatingStatement.java:237)rn at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:298)rn at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:234)rn at org.hibernate.loader.Loader.getResultSet(Loader.java:1967)rn at org.hibernate.loader.Loader.doQuery(Loader.java:802)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)rn at org.hibernate.loader.Loader.doList(Loader.java:2542)rn at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)rn at org.hibernate.loader.Loader.list(Loader.java:2271)rn at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:459)rn at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:365)rn at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)rn at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)rn at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)rn at com.jmy.logic.JEssayLogic.find(JEssayLogic.java:164)rn at com.jmy.service.impl.JEManagerImpl.find(JEManagerImpl.java:46)rn at com.jmy.action.JmyOnePage.loadPage(JmyOnePage.java:38)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:453)rn at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:292)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:255)rn at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)rn at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)rn at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)rn at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249)rn at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)rn at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510)rn at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)rn at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)rn at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)rn at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)rn at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)rn at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)rn at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)rn at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)rn at java.lang.Thread.run(Thread.java:619)[/code]这个错 goolge了一下 说是mysql断开一个长时没有响应的连接 我现在有个疑问 我已经把session都关闭了 再次访问的时候应该不存在长时间无响应 应该是重新创建session 为什么还会报上面的错
Operation not allowed after ResultSet closed
Operation not allowed after ResultSet closed这类问题基本上是因为什么的错误?
hibernate连接mysql数据库,总是会在一段时间后显示No operations allowed after connection closed
这里是我的配置文件,到底哪里有问题呢?rnrnrnrnrnrnrnrn rn org.hibernate.dialect.MySQLDialectrn com.mysql.jdbc.Driverrn rn jdbc:mysql://127.0.0.1:3306/health_center?useUnicode=true&characterEncoding=utf8rn rn rootrn rn truern truern UTF-8rn truern rn org.hibernate.connection.C3P0ConnectionProviderrn 5rn 20rn 1800rn 900rn select 1rn 50rn rn truern rn rnrn
No operations allowed after statement closed.错误-求助
请问一般No operations allowed after statement closed.是什么错误?rn报错如下:rnjava.sql.SQLException: No operations allowed after statement closed.rn at com.mysql.jdbc.Statement.checkClosed(Statement.java:277)rn at com.mysql.jdbc.Statement.executeQuery(Statement.java:870)rn at Display.main(Display.java:92)rn源程序rnsql="select * From Student";rnrn //read resultrnrntry rn ResultSet rs=stmt.executeQuery(sql);rnwhile(rs.next())rnrnrnrnString AgentName=rs.getString(1);rnrnSystem.out.println(AgentName+" ");rnrnrnrs.close();rnstmt.close();rnrn rn catch (Exception e) rn System.out.println("exceptin in excute the query!");rn e.printStackTrace(); rnrnrnrn是控制流的错误么?rnPS. 关于SQL语句肯定没错。。。
java.sql.SQLException: Operation not allowed after ResultSet closed
[code=Java]rnrnpackage com.gunxue.servlet;rnrnimport java.io.IOException;rnimport java.io.PrintWriter;rnimport java.security.MessageDigest;rnimport java.security.NoSuchAlgorithmException;rnimport java.sql.Connection;rnimport java.sql.ResultSet;rnimport java.sql.SQLException;rnimport java.sql.Statement;rnimport java.text.DateFormat;rnimport java.util.Date;rnrnimport javax.servlet.ServletException;rnimport javax.servlet.http.HttpServlet;rnimport javax.servlet.http.HttpServletRequest;rnimport javax.servlet.http.HttpServletResponse;rnrnimport org.apache.commons.logging.Log;rnimport org.apache.commons.logging.LogFactory;rnrn//import com.xifan.db.DB;rnimport com.gunxue.pushHttp.PushTask;rnimport com.gunxueapi.test.ConnectionPool;rnrn@SuppressWarnings("serial")rnpublic class Push extends HttpServlet rn private static final Log log = LogFactory.getLog(Push.class);rn public void doGet(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn doPost(request, response);rn rnrn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn request.setCharacterEncoding("utf-8");rn response.setContentType("text/html; charset=utf-8");rn PrintWriter out = response.getWriter();rnrn // 从url里得到得到用户名rn String cpid = request.getParameter("name");rn // 从url里得到密码rn String cppwd = request.getParameter("password");rn // 从url里得出电话rn String mobile = request.getParameter("phone");rn // 从url里得出内容rn String msgcontent = request.getParameter("mtContent");rn // 从URL里得到服务代码rn String spnumber = request.getParameter("spnumber");rn //取得当前时间rn Date date = new Date();rn DateFormat d2 = DateFormat.getDateTimeInstance(); rn String str2 = d2.format(date); rn /*rn * 服务器端rn */rn try rn String SQL = "select cpid,cppwd from userinfo where count>0";rn ConnectionPool pool = null;rn pool = ConnectionPool.getInstance();rn Connection conn = pool.getConnection();rn Statement stmt = conn.createStatement();rn ResultSet rs = stmt.executeQuery(SQL);rn while (rs.next()) rn String m5pwd=Push.Md5(rs.getString(2));rn if (cpid != null && !cpid.equals("")) rn if (rs.getString(1).equals(cpid.trim())) rn if (cppwd != null && !cppwd.equals("")) rn if (m5pwd.equals(cppwd.trim())) rn if (mobile != nullrn && !mobile.equals("")) rn if (msgcontent != nullrn && !msgcontent.equals("")) rn String resp = PushTask.work(mobile.trim(),msgcontent.trim());rn if (!resp.trim().equals("0")) rn SQL = "insert into pushcontent(cpid,mobile,content,spnumber,cpdatetime,flag) value('"rn + cpid.trim()rn + "','"rn + mobile.trim()rn + "','"rn + msgcontent.trim()rn + "','"rn + spnumberrn + "','"rn + str2rn + "',1)";rn stmt.executeUpdate(SQL);rn SQL = "update userinfo set count=count-1 where cpid='"rn + cpid.trim() + "'";rn stmt.executeUpdate(SQL);rn rn out.println("0");rn rn rn else rn SQL = "insert into pushcontent(cpid,mobile,content,spnumber,cpdatetime,flag) value('"rn + cpid.trim()rn + "','"rn + mobile.trim()rn + "','"rn + msgcontent.trim()rn + "','"rn + spnumberrn + "','"rn + str2rn + "',0)";rn stmt.executeUpdate(SQL);rn out.println("007");rn rn else rn out.println("006");// 内容为空rn rn else rn out.println("005");// 号码为空rn rn else rn out.println("004");// 密码不正确rn rn else rn out.println("003");// 密码为空rn rn else rn out.print("002");// 用户名不存在rn rn else rnrn out.println("001");// 没有填写用户名rn rn // log.info("["+ip+"]"+cpid+"/"+cppwd+""+mobile+""+msgcontent+"#"+spnumber+"#");rn rn rs.close();rn stmt.close();rn pool.release(conn);rn pool.closePool();rn catch (SQLException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (Exception e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rnrn private static String Md5(String m5pwd) rn String m5pw="";rn try rn MessageDigest md = MessageDigest.getInstance("MD5");rn md.update(m5pwd.getBytes());rn byte b[] = md.digest();rn int i;rn StringBuffer buf = new StringBuffer("");rn for (int offset = 0; offset < b.length; offset++) rn i = b[offset];rn if (i < 0)rn i += 256;rn if (i < 16)rn buf.append("0");rn buf.append(Integer.toHexString(i));rn rn m5pw=buf.toString().substring(8, 24);rn //System.out.println(m5pw);rn catch (NoSuchAlgorithmException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn return m5pw;rn rnrnrnrn[/code]rnrn报这个异常:rnjava.sql.SQLException: Operation not allowed after ResultSet closedrn at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)rn at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.java:655)rn at com.mysql.jdbc.ResultSet.next(ResultSet.java:7302)rn at com.gunxue.servlet.Push.doPost(Push.java:65)rn at com.gunxue.servlet.Push.doGet(Push.java:32)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)rn at java.lang.Thread.run(Thread.java:619)rn
org.apache.jasper.JasperException: Operation not allowed after ResultSet closed
相关流程:[code=Java]public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rn HttpSession mySession = request.getSession(true);rn mySession.setAttribute("errMsg", "");// 清空错误信息rnrn String username = request.getParameter("username"); // 获取参数值rn String password = request.getParameter("password");rnrn String identfiy = request.getParameter("identfiy");// 获取参数传来的验证码rnrn String sessionIdentiy = (String) mySessionrn .getAttribute("Login_Image_Code"); // 获取session里的验证码rnrn String conformPswd = "";rn String sql = "select * from user where username='" + username + "'";rnrn if (identfiy == "" || identfiy.length() < 1) // 验证码为能为空rnrn mySession.setAttribute("errMsg", "验证码不能为空!");rn response.sendRedirect("/loginuser/login.jsp");rnrn else if (!identfiy.toUpperCase().equals(sessionIdentiy.toUpperCase())) // 验证验证码是是否一致rnrn mySession.setAttribute("errMsg", "验证码错误!");rn response.sendRedirect("/loginuser/login.jsp");rn rnrn ResultSet rs = null;rn mvconnection mvc = new mvconnection();rn if (mvc != null) rn rs = mvc.getResultSet(sql);rnrn else rn return;rn rn if (rs != null) rn try rn while (rs.next()) rn if (rs.getString(3) != null) rn conformPswd = rs.getString(3);rn rnrn rn catch (SQLException e) rn e.printStackTrace();rn finally rn rn rn else rn mySession.setAttribute("errMsg", "用户名不存在!");rn response.sendRedirect("/loginuser/login.jsp");rn rnrn if (password.equals(conformPswd)) rnrn if (username.equals("guest")) rn sql = "select * from user where enroll= 0";rn rs = mvc.getList(sql);rn mySession.setAttribute("rs", rs);rnrn response.sendRedirect("/loginuser/guest.jsp");rnrn else if (username.equals("admin")) rnrn sql = "select * from user where enroll= 1"; // 通过的rn rs = mvc.getList(sql);rn mySession.setAttribute("rs", rs);rn RequestDispatcher requestDispathcer = request.getRequestDispatcher("/admin.jsp");rn requestDispathcer.forward(request, response);rnrn else if (username.equals("user")) rnrn sql = "select * from user where enroll= 1"; // 通过的rn rs = mvc.getList(sql);rn // set attribute herern mySession.setAttribute("rs", rs);rn response.sendRedirect("/loginuser/user.jsp");rnrn rn else rn return;rn rnrn rn rn[/code]rnrn[code=Java]public ResultSet getList(String sql) rn ResultSet rs = null;rn Statement stmt = null;rn Connection con = null;rn con = this.dbC.getConnection();rn if (con != null) rn try rn stmt = con.createStatement();rn if (stmt != null) rn rs = stmt.executeQuery(sql);rn if (rs != null) rn return rs;rn else rn return null;rn rn else rn return null;rn rn catch (SQLException e) rnrn e.printStackTrace();rn return null;rn rnrn else rn return null;rn rnrn [/code]rnrnrn[code=HTML]<%@ page language="java" pageEncoding="gb2312"%>rn<%@ page import ="java.sql.*" %>rn<%rn ResultSet rs = null;rn if(session.getAttribute("rs")!=null)rn Object ob = session.getAttribute("rs");rn rs = (ResultSet)ob;rn rn %>rnrnrn rn <%rn System.out.println(request.getRequestURL());rn rn %>rn rn adminrn rn rn rn rn rn rn rnrn rn rn rn rn id 用户名 简历信息 审核情况 是否录取 操作rn <%rn while(rs.next())rn %>rn <%=rs.getInt("id")%> <%= rs.getString("username") %> <%=rs.getString("info") %>rn <%=rs.getString("enroll") %> <%= rs.getString("verify") %> 修改 删除rn <% %>rn rn rnrn[/code]rnHTTP Status 500 - rnrn--------------------------------------------------------------------------------rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: After end of result setrn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:460)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnroot cause rnrnjavax.servlet.ServletException: After end of result setrn org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)rn org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)rn org.apache.jsp.update_jsp._jspService(update_jsp.java:106)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnroot cause rnrnjava.sql.SQLException: After end of result setrn com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)rn com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java:709)rn com.mysql.jdbc.ResultSet.getInt(ResultSet.java:2605)rn org.apache.jsp.update_jsp._jspService(update_jsp.java:73)rn org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:803)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.rnrnrn--------------------------------------------------------------------------------rnrnApache Tomcat/5.5.25[color=#FF0000]我rs都没有关啊,怎么会有After end of result set错误[/color]
Operation not allowed after ResultSet closed异常
写了个递归方法,但是老报错,说rs已经关闭,但怎么查也查不出来,上网百度找了找,都不对,求大婶指点rn <%!rn String str="";rn private void tree(Connection conn,int id,int level)rn String preStr="";rn Statement stmt=null;rn ResultSet rs=null;rn String sql="select * from article where pid="+ id;rn rn for(int i=0;i"+rn ""+preStr+ rs.getString("title")+"";rn rn if(rs.getInt("isleaf")!=0)rn tree(conn,rs.getInt("id"),level+1);rn rn rn catch(SQLException e)rn e.printStackTrace();rn finallyrn tryrn if(rs!=null)rn rs.close();rn rn if(stmt!=null)rn stmt.close();rn rn if(conn!=null)rn conn.close();rn rn catch(SQLException e)rn e.printStackTrace();rn rn rn rn %>rn <%rn Connection conn=DB.getConn();rn Statement stmt=DB.getStmt(conn);rn ResultSet rs=null;rn //输出主题帖 rn String sql="select * from article where pid=0";rn rs=stmt.executeQuery(sql);rn tryrn while(rs.next())rn System.out.println("oh my fuck");rn str=""+ rs.getInt("id")+""+rn ""+ rs.getString("title")+"";rn if(rs.getInt("isleaf")!=0)rn System.out.println("oh my fuckking");rn tree(conn,rs.getInt("id"),1);rn System.out.println("wocao");rn rn rn catch(SQLException e)rn e.printStackTrace();rn rn finallyrn System.out.println("fuck");rn DB.close(rs);rn rs=null;rn System.out.print("shit");rn DB.close(stmt);rn stmt=null;rn DB.close(conn);rn conn=null;rn rn %>[code=java][/code]
The underlying connection was closed: The connection was closed unexpectedly.
The underlying connection was closed: The connection was closed unexpectedly.rnrnrn在连接远程服务的时候提示这个。和数据库没有关系。因为调用的是HELLOWORLD方法来测试。是不是IIS需要重启动呢。rn谢谢大家。
connection is closed
各位同行:rnrn 我的系统比较烂,计算工资的速度很慢,结果在计算的过程中出现了该页无法显示:rnrn 服务器报错为:rnrn java.lang.nullpointerException java.sql.sqlEXception :rnrnconnection is closed
The connection is closed
请问,在页面打开得太多太快的时侯,有时会出现"The connection is closed"的警告,请问是为什么?
求助:关于java.sql.SQLException: Operation not allowed after ResultSet closed的问题
我的源代码如下rn<%@ page contentType="text/html; charset=GBK" %>rn<%@ page import="java.sql.*,java.util.*,com.info.bean.*,com.info.inc.*"%>rn<%@ include file="islogin.jsp"%>rn<%@ include file="isadmin.jsp"%>rn<%rnConnection conn = null;rnPreparedStatement ps = null;rnResultSet rs = null;rnPreparedStatement ps2 = null;rnResultSet rs2 = null;rnconn=dbconn.getconnection();rncomm commhtml = new comm();rnString htmlhead ="";rnhtmlhead = commhtml.HtmlHead("友情提示");rnout.println(htmlhead);rnrnrn%>rn rn rn rn rn回复信息提示:(点击信息标题可以直接进入)rn rn<%rnString StrSql;rnStrSql="select * from info_info where guidang=0 and recontent!='' and recontent is not null and isback=0";rnStrSql= StrSql + " order by updatetime desc,dateyear desc,yearid desc limit 0,20";rn//ps = conn.prepareStatement(StrSql);rnps= conn.prepareStatement(StrSql);rnrs = ps.executeQuery();rnrnwhile (rs.next())rnrn %>rn <%=rs.getString("AdminUnit")%> 对 "><%=rs.getString("Info_Title")%> 信息做了回复 (<%=rs.getString("Info_Time").substring(0,10)%>)。 rn <%rnrnrnrnrnrnrnString StrSql2;rnStrSql2="select * from info_info where isback=1 order by updatetime desc,dateyear desc,yearid desc limit 0,20 ";rn//ps2 = conn.prepareStatement(StrSql2);rnps2 =conn.prepareStatement(StrSql2);rnrs2 = ps2.executeQuery();rnint r=0;rnrn%>rn rn退回信息提示:(点击信息标题可以直接进入)rn rn<%rnrnwhile (rs2.next())rnrn r=1;rn %>rn <%=rs2.getString(9)%> 信息被退回 (<%=rs2.getString(11).substring(0,10)%>)。 rn <%rnrnrnif(r==1)rnrn %>rn rnrn <%rnrnrn%>rnrnrn<%rnrs2.close();rnrs2=null;rnps2.close();rnps2=null;rnrs.close();rnrs=null;rnps.close();rnps=null;rndbconn.closeconnection();rnconn=null;rnout.println(commhtml.HtmlTail());rncommhtml=null;rnrn目前的问题是,我是读取了两遍数据库,也是使用两个PreparedStatement 和两个ResultSet 来做的,但是它有时候就好使,没有问题,有时候刷新的话 就会出现java.sql.SQLException: Operation not allowed after ResultSet closed的错误,改了好多遍,都不知道错误在哪里,哪位大哥知道啊。愁死了!rnrn十万分感谢啊!
我的ResultSet 报Operation not allowed after ResultSet closed???
我用了两个resultset,并且分别用两个statement创建。怎么还报上面的那个错。
SQLException: Operation not allowed after ResultSet closed 如何避免?
stmt=conn.createStatement();rn rs=stmt.executeQuery(sql_b);rn rst=stmt.executeQuery(sql_a);rn rs.last();//当执行了 rst=stmt.executeQuery(sql_a);rs就会被关闭掉!rn int n=rs.getRow();rn rst.last();rn int m=rst.getRow();rnrn请问我该怎么做?才能避免被关闭掉。rn还有createStatement()里面有几个参数,那几个参数代表什么?谢谢各位
Write operations are not allowed in read-only mod......
今天在做spring2.x+struts2.0+hibernate3.x的项目时候,在执行更新操作的时候,出现的问题,大家帮助给看一下:rnrnorg.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.rn at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1095)rn at org.springframework.orm.hibernate3.HibernateTemplate$14.doInHibernate(HibernateTemplate.java:656)rn at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)rn at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:654)rn at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:650)rn at com.dacc.dcp.dao.impl.DPourRecordDAO.saveOrUpdateDPourRecord(DPourRecordDAO.java:61)rn at com.dacc.pp.service.impl.DHeatRecordService.saveOrUpdateDPourRecord(DHeatRecordService.java:29)rn at com.dacc.pp.action.Pouring_updateWheelAction.updateWheelInfo(Pouring_updateWheelAction.java:52)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn rn----------------------------------------------------------------------------------------rnweb.xmlrnrn rn contextConfigLocation rn /WEB-INF/classes/bean.xml rn rn rn rn org.springframework.web.context.ContextLoaderListener rn rn rn rn lazyLoadingFilter rn org.springframework.orm.hibernate3.support.OpenSessionInViewFilter rn rn singleSessionrn truern rn rn rn struts2rn org.apache.struts2.dispatcher.FilterDispatcherrn rn rn lazyLoadingFilterrn *.actionrn rn rn struts2rn /*rn rn rn index.jsprn rnrnrnrn----------------------------------------------------------------------------------------rnspring 配置文件rnrnrn rn rn rn rn rn rn rn rn rn rn rn PROPAGATION_REQUIRED,readOnlyrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn rn rn rn rn rn rn rn rn DHeatRecordServiceImplrn DPourRecordServiceImplrn rn rn rn rn rn rn transactionInterceptorrn rn rn rn rn rn rn ......rnrn---------------------------------------------------------------------------------rnDao 层rnrn public int saveOrUpdateDPourRecord(DPourRecord vo)rn log.debug("save or update object");rn rn DPourRecord bean = findDPourRecordByWheelCode(vo.getWheelCode());rn System.out.println(bean.getPourId());rn bean.setWheelCode(vo.getWheelCode());rn bean.setCopeNo(vo.getCopeNo());rn bean.setCopeScrap(vo.getCopeScrap());rn bean.setTestCode(vo.getTestCode());rn bean.setDragScrap(vo.getDragScrap());rn bean.setSpecialUltra(vo.getSpecialUltra());rn bean.setStates(vo.getStates());rn rn try rn getHibernateTemplate().update(bean);rn getHibernateTemplate().flush();rnrn catch (RuntimeException e) rn log.error("save or update object failed!");rn e.printStackTrace();rnrn rn rn return 0;rn rnrnrn------rnrn//通过车轮号查找对象rn public DPourRecord findDPourRecordByWheelCode(String wheelCode)rn log.debug("find id by wheelCode!");rn List paramsList = new ArrayList();rn List objectList = new ArrayList();rn paramsList.add(wheelCode);rn System.out.println(wheelCode);rn String strSql = "From DPourRecord where wheel_code =?";rn DPourRecord dpr;rn try rn dpr =(DPourRecord) getHibernateTemplate().find(strSql, paramsList.toArray()).get(0);rn rn catch (RuntimeException e) rn log.error("find id by wheel_code is failed!");rn throw e;rn rn return dpr;rn rnrn---------------------rn请大家帮助给看一下,项目着急在用!,在网上查的说去掉spring 配置文件不必要的readyOnly ,还有说修改web.xml 文件,我照做,还是没解决问题
operation is not allowed on an object referencing a closed or invalid connection
用同一段代码给一个adoquery和一个adoconnecton的connectionstring赋值(从配置文件中读取并组合),一个放在adoquery的连接放在login窗口的create事件里,adoconnection的连接放在main窗口的create时间里,登陆窗口的登陆按钮调用main的create()方法,但是adoquery连接没问题,只有adoconnection始终连不上,提示“operation is not allowed on an object referencing a closed or invalid connection”错误,不知道怎么回事
dbcp 连接池 connection is closed
做单元测试时,数据库的connection 会自动关闭,项目使用的框架式springmvc+ibatis+mysql 数据连接池是用dbcp 。做单元测试时,如果有一个方法连接查询到数据库,第二个方法再连接查询就会报connection is closed 。
connection closed gracefully
在coldfusion bulider 这个RDS 的配置能测试通过。rn[img=http://img851.ph.126.net/I_-JAd6xMKEvRXDJ2tPJmw==/2719048275025503107.jpg][/img]rnrn而在coldfusion report builder 里配置的测试出现[color=#FF0000] connection closed gracefully[/color] 的错误rn[img=http://img612.ph.126.net/5yqyUXHU5Ing1b1nj_6geA==/1701797709194133621.jpg][/img]rnrn请问哪位大侠知道这是什么问题啊。rnconnection closed gracefully 一般是因为什么呢。rn谢谢。
ORA-12537: TNS:connection closed
服务器操作系统:linuxrn数据库:oracle9.2.0rn客户端:win2000sp4rnrn服务器端:lisener,数据库已启动,本地可以使用,数据库端口1521rnlisener.ora:rnVIS =rn (ADDRESS_LIST =rn (ADDRESS= (PROTOCOL= IPC)(KEY= EXTPROCVIS))rn (ADDRESS= (PROTOCOL= TCP)(Host= server)(Port= 1521))rn )rnrnSID_LIST_VIS =rn (SID_LIST =rn (SID_DESC =rn (ORACLE_HOME= /orahome/server/9.2.0)rn (SID_NAME = VIS)rn )rn (SID_DESC =rn (SID_NAME = PLSExtProc)rn (ORACLE_HOME = /orahome/server/9.2.0)rn (PROGRAM = extproc)rn )rn )rnrnSTARTUP_WAIT_TIME_VIS = 0rnCONNECT_TIMEOUT_VIS = 10rnTRACE_LEVEL_VIS = OFFrnrnLOG_DIRECTORY_VIS = /orahome/server/9.2.0/network/adminrnLOG_FILE_VIS = VISrnTRACE_DIRECTORY_VIS = /orahome/server/9.2.0/network/adminrnTRACE_FILE_VIS = VISrnADMIN_RESTRICTIONS_VIS = OFFrnrnrnIFILE=/orahome/server/9.2.0/network/admin/listener_ifile.orarnrnrnrn客户端:连接数据库报错:‘ORA-12537: TNS:connection closed’rn客户端tnsname已经配置。rntnsname.ora:rnVIS=rn (DESCRIPTION=rn (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.22.22)(PORT=1521))rn (CONNECT_DATA=rn (SERVICE_NAME=VIS)rn (INSTANCE_NAME=VIS)rn )rn )rnrn请问如何解决。rnrn
The connection is closed 的问题
当程序运行到:clob.Write(buffer,0,100); 提示:Invalid operation. The connection is closed 但我在该句前面加入 myCn.Open(); 又出错:Invalid operation. The connection is open rn/// rn ///oracle 对长字符串的操作--写入rn /// rn /// for update 语句rn /// 长字符串的列rn /// 字符串内容rn rn void WriteLob(string up_sql,int column,string content)rn rn OracleConnection myCn = new OracleConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnenctionString"]); rn OracleCommand myCmd = new OracleCommand(); rn try rn rn myCn.Open(); rn rn catch(System.Data.OracleClient.OracleException e) rn rn throw new Exception(e.Message); rn rn OracleTransaction myTrans = myCn.BeginTransaction(); rn try rn rn myCmd.Connection = myCn; rn myCmd.Transaction = myTrans; rn myCmd.CommandText = up_sql; rn OracleDataReader reader = myCmd.ExecuteReader(); rn using(reader) rn rn reader.Read(); rn rn rn OracleLob clob = reader.GetOracleLob(column);//column为lob类型所在列 rn rn Encoding UTF8 = Encoding.UTF8; //使用UTF-8进行编码 rn byte[] buffer = UTF8.GetBytes(content); rn if(buffer.Length % 2 ==0) rn rn rn if(clob.CanWrite)rn rn rn clob.Write(buffer,0,100); //这里的参数必须为偶数 rn rn rn rn else rn rn clob.Write(buffer, 0, (buffer.Length - 1)); rn rn //clob.Position = 0; rn myTrans.Commit(); rn rn rn rn catch(System.Data.OracleClient.OracleException e) rn rn myTrans.Rollback(); rn throw new Exception(e.Message); rn rn finally rn rn myCmd.Dispose(); rn myCn.Close(); rn rnrnrnrnrnrn
Connection closed gracefully 问题
参考了一些网络上关于文件传输的资料,用IdTCPClient1,IdTCPSever写了一个传输文件的程序,在传输过程中传输端有时会爆“ Connection closed gracefully”或“Socket Error #10054 Connection reset by peer.”错误,出现后者情况时,一般是在接收端自动关闭(没有报异常),这是一端被强制关闭造成的,查了一天也找不出源头。搞得很郁闷。。rn现把程序列出来,哪个高手帮忙分析下,到底是哪出问题了。。。rnrn传输端:rnProcedure TMainForm.SendFile(pFilePath:String);rnvarrn dir,sFile,lCmd:String;rn Rdir:Stringarray;rn fSize,iFileType,iFileIndex,i:integer;rn lFileSize,ASize:Int64;rn lFileSendSize:integer;rnbeginrnrn TmSendDBFile.Enabled := False;rn tryrn PClient := Tidtcpclient.Create(nil);rn PClient.Host := F_RemoteServerIP;//'192.168.0.20';//fip;rn PClient.Port := 9923;rn sleep(3000);rn PClient.Connect();rnrn if PClient.Connected thenrn beginrn PClient.WriteLn('START'); //通知客户端开始传输rn PClient.WriteLn(IntToStr(F_DBUpdateFileCount)); //DB文件个数rn PClient.WriteLn(IntToStr(F_MediaUpdateFileCount)); //Media文件个数rnrn iFileType := StrToInt(PClient.ReadLn()); //接收要发送的文件类型rn //发送DB文件rn if iFileType = 0 thenrn beginrn repeatrn i:=0;rn iFileIndex := StrToInt(PClient.ReadLn()); //接收要发送的文件索引rn F_FileName := F_DBUpdateFile[iFileIndex].sFile;rn PClient.WriteLn(F_FileName);rn sFile := ExtractFilePath(Application.ExeName) + 'db\' + F_FileName;rn red_NetUpdate.Lines.Append('['+TimetoStr(Now())+'] 发送文件:'+sFile);rn F_FileStream := TFileStream.Create(sFile,fmopenread);rn lFileSize := F_FileStream.Size;rn PClient.writeln(IntToStr(lFileSize));rnrn lFileSendSize := StrToInt(PClient.ReadLn); //客户端发送的命令字符串rn while lFileSendSize<=lFileSize dorn beginrn if FSendAgainFlag thenrn beginrn //取已接收文件流的大小rn if i<>0 then ////////////////报“Socket Error #10054 Connection reset by peer”//////////////rn lFileSendSize := StrToInt(PClient.ReadLn);rn rn //当cmd返回0时,表示文件接收完毕,退出循环rn if (lFileSendSize=0) and (i<>0) thenrn break;rn //按照指定位置传输文件rn F_FileStream.Seek(lFileSendSize, soFromBeginning);rn //转到文件流传输的位置rn ASize := Min(F_FileStream.Size - F_FileStream.Position, PClient.RecvBufferSize);rn //计算需要发送的大小,Min()函数在Math单元rn PClient.OpenWriteBuffer; //准备发送缓冲rn PClient.WriteStream(F_FileStream, false, false, ASize);rn //显示进度条rn if F_FileStream.Size<>0 thenrn pb_Progress.Position := F_FileStream.Position * 100 div F_FileStream.Sizern elsern pb_Progress.Position := 0;rn lbl_FileName.Visible := True;rn pb_Progress.Visible := True;rnrn PClient.CloseWriteBuffer; //结束发送缓冲rn inc(i);rn end;rn end;rn FSendDBCount := FSendDBCount+1;rn F_FileStream.Free;rn red_NetUpdate.Lines.Append('['+TimetoStr(Now())+'] 文件:'+sFile+',发送完成!');rn until F_DBUpdateFileCount = FSendDBCount;rn end;rnrn if F_MediaUpdateFileCOunt = 0 thenrn red_NetUpdate.Lines.Append('无多媒体传输文件,请确认!')rn elsern //发送media文件rn repeatrn i:=0;rn iFileIndex := StrToInt(PClient.ReadLn()); //接收要发送的文件索引rn F_FileName := F_MediaUpdateFile[iFileIndex].sFile;rnrn PClient.WriteLn(F_FileName);rn sFile := ExtractFilePath(Application.ExeName) + 'media\' + F_FileName;rn red_NetUpdate.Lines.Append('['+TimetoStr(Now())+'] 发送文件:'+sFile);rn F_FileStream := TFileStream.Create(sFile,fmopenread);rn lFileSize := F_FileStream.Size;rnrn PClient.writeln(IntToStr(lFileSize)); //传输文件大小rnrn lFileSendSize := StrToInt(PClient.ReadLn); //客户端发送的命令字符串rn while lFileSendSize<=lFileSize dorn beginrn if FSendAgainFlag thenrn beginrn //取已接收文件流的大小rn if i<>0 thenrn beginrn tryrn lFileSendSize := StrToInt(PClient.ReadLn);rn exceptrn Showmessage('123');rn end;rn end;rn //当cmd返回0时,表示文件接收完毕,退出循环rn if (lFileSendSize=0) and (i<>0) thenrn break;rn //按照指定位置传输文件rn F_FileStream.Seek(lFileSendSize, soFromBeginning);rn //转到文件流传输的位置rn ASize := Min(F_FileStream.Size - F_FileStream.Position, PClient.RecvBufferSize);rn //计算需要发送的大小,Min()函数在Math单元rn PClient.OpenWriteBuffer; //准备发送缓冲rn PClient.WriteStream(F_FileStream, false, false, ASize);rn //显示进度条rn if F_FileStream.Size<>0 thenrn pb_Progress.Position := F_FileStream.Position * 100 div F_FileStream.Sizern elsern pb_Progress.Position := 0;rn lbl_FileName.Visible := True;rn pb_Progress.Visible := True;rnrn PClient.CloseWriteBuffer; //结束发送缓冲rn inc(i);rn end;rn end;rn FSendMediaCount := FSendMediaCount+1;rn F_FileStream.Free;rn red_NetUpdate.Lines.Append('['+TimetoStr(Now())+'] 文件:'+sFile+',发送完成!');rn until F_MediaUpdateFileCOunt = FSendMediaCount;rnrn //接到END表示结束文件传输rn if PClient.ReadLn='END' thenrn beginrn //showmessage('模块升级1');rn PClient.DisconnectSocket;rn end;rn red_NetUpdate.Lines.Add('★★★'+TimetoStr(Now())+' 文件发送完毕!★★★');rn end;rn finallyrn //showmessage('模块升级2');rn PClient.DisconnectSocket;rn PClient.Free;rn end;rnend;rnrn接收端:rnprocedure TMainForm.PServerExecute(AThread: TIdPeerThread);rnvarrn cmd,targetname:string;rn lsize:int64;rn fs:tfilestream;rn ASize:int64;rn iFileIndex,iFileType:integer;rnbeginrn with athread.Connection dorn beginrn cmd:=trim(readln);rn if cmd='START'thenrn beginrn FRevDBCount := StrToInt(readln); //要接收DB文件个数rn FRevMediaCount := StrToInt(readln); //要接收meidia文件个数 ,rn //接收db文件rn Repeatrn if FDbCount = 0 thenrn beginrn iFileIndex := 0;rn iFileType := 0;rn writeln(IntToStr(iFileType)); //发送文件类型rn endrn elsern iFileIndex := iFileIndex+1;rnrn writeln(IntToStr(iFileIndex)); //发送文件索引rn targetname := FDBFilePath+readln;rn //lbl_FileName.Caption :='正在接收文件:'+ targetname;rn lSize := StrToIntDef(readln,0); //接收文件大小rn try //循环开始接受rn //建立文件流准备接收rn fs := TFileStream.Create(targetname, fmCreate);rn repeatrn WriteLn(IntToStr(fs.Size));//发送当前传输的位置rn ASize := Min(lsize - fs.Size, RecvBufferSize);rn //选择剩余大小和缓冲区大小小的一个作为传输的大小rn ReadStream(fs, ASize); //接收流rn lbl_Progress.Caption :='当前传输位置'+ IntToStr(fs.Size) + '/大小' + IntToStr(lsize);rn Application.ProcessMessages;rn until fs.Size = lsize; //大小一致了表示结束rn FDbCount := FDbCount+1 ;rn WriteLn('0');//写‘0’表示告知客户端上一文件已经接收完毕rn finallyrn fs.Free; //释放文件流rn end;rn until FRevDBCount = FDbCount;rn //接收media文件rn Repeatrn if FMediaCount = 0 thenrn beginrn iFileIndex := 0;rn //iFileType := 0;rn //writeln(IntToStr(iFileType)); //发送文件类型rn endrn elsern iFileIndex := iFileIndex+1;rnrn writeln(IntToStr(iFileIndex)); //发送文件索引rn targetname := FMediaFilePath+readln;rn lSize := StrToIntDef(readln,0); //接收文件大小rn try //循环开始接受rn //建立文件流准备接收rn fs := TFileStream.Create(targetname, fmCreate);rn repeatrn WriteLn(IntToStr(fs.Size));//发送当前传输的位置rn mmo_Report.Lines.Append(IntToStr(fs.Size));rn ASize := Min(lsize - fs.Size, RecvBufferSize);rn //选择剩余大小和缓冲区大小小的一个作为传输的大小rn ReadStream(fs, ASize); //接收流rn lbl_Progress.Caption :='当前传输位置'+ IntToStr(fs.Size) + '/大小' + IntToStr(lsize);rn Application.ProcessMessages;rn until fs.Size = lsize; //大小一致了表示结束rn FMediaCount := FMediaCount+1 ;rn WriteLn('0');//写‘0’表示告知客户端上一文件已经接收完毕rn finallyrn fs.Free; //释放文件流rn end;rn until FRevMediaCount = FMediaCount;rnrn writeln('END');rn lbl_Progress.Caption :='当前传输位置'+ IntToStr(0) + '/大小' + IntToStr(0);rn lbl_FileName.Caption :='文件接收完毕!';rn //UpdateDB;rn //EndRun(DEF_ALARM_END) ;rn if FRevMediaCount+FRevDBCount = FMediaCount+ FDbCount thenrn disconnect;rn end;rn end;rnrnend;
java.sql.SQLException: Closed Connection
本机上运行一个程序,用的是java1.5, oracle9,正常!rn将程序移植到unix服务器上之后,执行了几次查询数据库的操作之后,就报错为:“java.sql.SQLException: Closed Connection ”。rn我的DB连接方式是程序开始就连上,到程序结束时才断开的。rnWhy?? 请高手指点!!!
高手帮忙!Write operations are not allowed in read-
WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final org.hibernate.SessionFactory org.springframework.orm.hibernate3.support.HibernateDaoSupport.getSessionFactory()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,203 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final void org.springframework.orm.hibernate3.support.HibernateDaoSupport.setSessionFactory(org.hibernate.SessionFactory)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,218 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final org.springframework.orm.hibernate3.HibernateTemplate org.springframework.orm.hibernate3.support.HibernateDaoSupport.getHibernateTemplate()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,218 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final void org.springframework.orm.hibernate3.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,218 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final void org.springframework.dao.support.DaoSupport.afterPropertiesSet() throws java.lang.IllegalArgumentException,org.springframework.beans.factory.BeanInitializationException] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,718 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final org.hibernate.SessionFactory org.springframework.orm.hibernate3.support.HibernateDaoSupport.getSessionFactory()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,718 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final void org.springframework.orm.hibernate3.support.HibernateDaoSupport.setSessionFactory(org.hibernate.SessionFactory)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,718 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final org.springframework.orm.hibernate3.HibernateTemplate org.springframework.orm.hibernate3.support.HibernateDaoSupport.getHibernateTemplate()] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,734 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final void org.springframework.orm.hibernate3.support.HibernateDaoSupport.setHibernateTemplate(org.springframework.orm.hibernate3.HibernateTemplate)] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rn2008-04-02 13:00:09,734 WARN [org.springframework.aop.framework.Cglib2AopProxy] - Unable to proxy method [public final void org.springframework.dao.support.DaoSupport.afterPropertiesSet() throws java.lang.IllegalArgumentException,org.springframework.beans.factory.BeanInitializationException] because it is final: All calls to this method via a proxy will be routed directly to the proxy.rnrn WARN [org.apache.struts.chain.commands.AbstractExceptionHandler] - Unhandled exceptionrnorg.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.rn at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1095)rn at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:634)rn我的配置文件是这样的rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn com/baoxiu/po/Baoxiulist.hbm.xmlrn com/baoxiu/po/User.hbm.xmlrn rn rn rn rn rn org.hibernate.dialect.MySQLDialectrn rn truern truern rn rn rnrnrnrnrn rn rn rn rn rn rnrnrn rn rn rn rn rn rnrn rn rn rn rn rn rn rn rn rn rnrn rnrn rnrn rnrn rn rn rn rn rn rn rn PROPAGATION_REQUIRED,readOnlyrn PROPAGATION_REQUIRED,readOnlyrn PROPAGATION_REQUIRED,readOnlyrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrn PROPAGATION_REQUIREDrnrn rn rnrn rn rnrn rnrn rn rn rn rn rn rn rn PROPAGATION_REQUIREDrn PROPAGATION_REQUIRED,readOnlyrn rn rnrn rnrnrnrnrn rnrnrnrn rn rn rn rn rn rn rn rn rn rnrnrnrnrn
Write operations are not allowed in read-only mode (FlushMode.MANUAL)
[img=https://img-bbs.csdn.net/upload/201507/05/1436102799_783564.jpg][/img]rn[img=https://img-bbs.csdn.net/upload/201507/05/1436102844_730247.jpg][/img]rn[img=https://img-bbs.csdn.net/upload/201507/05/1436102886_267059.jpg][/img]rn保存的时候报错,大虾帮我看看,拜谢
错误:Write operations are not allowed in read-only mode求教
执行saveOrUpdate方法:rnrn[code=Java]getHibernateTemplate().saveOrUpdate(instance);[/code]rnrn错误信息:rnexception rnrnjavax.servlet.ServletException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.rnrnroot cause rnrnorg.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.rnrnrn请问怎么回事呢?
Connection Closed Gracefully,Indy.IdHTTP的错误
求教,如何修改? post后提示 Connection Closed Gracefully 且无返回值
网站测试小问题 The connection was not closed ……
网址:rnwww.szdchj.comrn点中文版。多进几次就报错了rnrn相关代码如下:rnpublic DataSet ReDataSet(string sSql)rn rn tryrn rn //if (Sconn.State != ConnectionState.Open)rn //rn // Sconn.Open();rn //rn if (Sconn.State == ConnectionState.Closed)rn rn Sconn.Open();rn rn DataSet Ds = new DataSet();rn OleDbDataAdapter Da = new OleDbDataAdapter(sSql, Sconn);rn Da.Fill(Ds);rn return Ds;rn rn catch (Exception ex)rn rn throw new Exception(ex.Message, ex);rn rn finallyrn rn CloseConn(); rn rn rnrn说明: 屏蔽的3行是原来的,下面3行是我写上去的,我感觉应该和原来是等同的。请指教,小弟在线等
登录时报错 connection is closed
我用struts2.0做的网站,tomcat做服务器,连接数据库的方式为,数据库连接池,用一个静态方法进行连接,代码如下rnpublic static Connection getConnection()rn Connection conn = null;rn try rn Context c = new InitialContext();rn DataSource ds = (DataSource)c.lookup("java:comp/env/jdbc/jlbzy");rn conn = ds.getConnection();rn catch (NamingException e) rn e.printStackTrace();rn catch (SQLException e) rn e.printStackTrace();rn rn return conn;rn rn每次获取连接时用 DB.getConnection(),用完了就conn.closed,自己测试时大多数情况下还没发现问题,只有登录的时候,当执行到conn.closeed的时候, 会报一个conection is closed的错。
总是提示:Operation is not allowed when the object is closed
原语句:<% dim rs,sqlrnset rs=server.createobject("adodb.recordset")rnsql="select * from query1 "rnrs.open sql,hgsconn,1,1rnif rs.eof and rs.bof then rn response.write " 没有数据"rn elserndo while not rs.eofrnrs.movenextrnlooprnend if rnrs.closern%>rnrn总是提示:Operation is not allowed when the object is closedrn怎么解决?
error: Link tests are not allowed after GCC_NO_EXECUTABLES
我在建立arm交叉编译环境遇到这个问题,在谷歌上查找有很多遇到这个问题的,但是没有一个是合适的解决方案,各位大神帮帮忙解决一下rnchecking whether the /home/embedded/build-bools/build-gcc/./gcc/xgcc -B/home/embedded/build-bools/build-gcc/./gcc/ -B/home/embedded/tools/arm-linux/bin/ -B/home/embedded/tools/arm-linux/lib/ -isystem /home/embedded/tools/arm-linux/include -isystem /home/embedded/tools/arm-linux/sys-include linker (/home/embedded/build-bools/build-gcc/./gcc/collect-ld) supports shared libraries... yesrnchecking whether -lc should be explicitly linked in... nornchecking dynamic linker characteristics... configure: error: Link tests are not allowed after GCC_NO_EXECUTABLES.rnmake[1]: *** [configure-target-libstdc++-v3] Error 1rnmake[1]: Leaving directory `/home/embedded/build-bools/build-gcc'rnmake: *** [all] Error 2rn
The system Message Box that is closed atuomatically after so
The system Message Box that is closed atuomatically after some time(21KB)
hibernate配置c3po连接池后:无法使用jdbc查询?报错Operation not allowed after ResultSet closed
代码段:rnrn[code=Java]PreparedStatement st = null;rn Session session = getSession();rn ResultSet rs = null;rn String sql = "select id,user_id,content,isaviable,createtime,business_info_id,overallimpression,discuss_sub_count,collection_count,read_status,forward_count from business_discusses a,( select max(id) as ids from business_discusses where isaviable = true group by business_info_id) b where a.id = b.ids order by createtime desc LIMIT 0,10";rn List list = new ArrayList();rn try rn// Transaction t = session.beginTransaction();rn st = session.connection().prepareStatement(sql);rn rs = st.executeQuery();rn// t.commit();rn UsersDAO userDao = new UsersDAO();rn rn BusinessInfoesDAO infoDao = new BusinessInfoesDAO();rn while (rs.next()) rn BusinessDiscusses dis = new BusinessDiscusses();rn dis.setId(rs.getInt("id"));rn dis.setUsers(userDao.findById(rs.getInt("user_id")));rn dis.setBusinessInfoes(infoDao.findById(rs.getInt("business_info_id")));rn dis.setContent(rs.getString("content"));rn dis.setIsaviable(rs.getBoolean("isaviable"));rn dis.setCreatetime(rs.getTimestamp("createtime"));rn dis.setOverallimpression(rs.getInt("overallimpression"));rn dis.setDiscussSubCount(rs.getInt("discuss_sub_count"));rn dis.setCollectionCount(rs.getInt("collection_count"));rn dis.setReadStatus(rs.getBoolean("read_status"));rn dis.setForwardCount(rs.getInt("forward_count"));rn list.add(dis);rn rn return list;rnrn catch (Exception e) rn e.printStackTrace();rn return null;rn finally rn try rn if (rs != null) rnrn rs.close();rn rn if (st != null) rn st.close();rn rn catch (SQLException e) rn e.printStackTrace();rn rn [/code]rnrnrnrn
相关热词 c# 标准差 计算 c#siki第五季 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池