SSH配置数据源问题applicationContext.xml文件
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/testinfo</value>
</property>
</bean>context.xml<Resource name="jdbc/testinfo"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/testinfo?useUnicode=true&characterEncoding=gbk"
username="root"
password="luruibing"
maxActive="100"
maxIdle="30"
maxWait="10000" />
这样配置是可以运行,关键就是有时候会出现以下错误~~~我不知道原因~~请大家帮助一下~~谢谢你们~~~
错误信息是:
org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
at org.hibernate.loader.Loader.doQuery(Loader.java:390)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 34 more它说无法执行query方法,
但是有大部分不会出现这样的错,就是有时候在注册,或者登陆的时候出现,但是刷新就没有问题了
为什么会出现这样的问题??
这个错误的原因在那?
如果是配置问题,那么怎么还是可以运行?还是可以显示数据?
或者你们直接给我回复一个你们的数据源配置嘛~~~谢谢
我用的是tomcat 6.0 SSH MYSQL 5.0
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/testinfo</value>
</property>
</bean>context.xml<Resource name="jdbc/testinfo"
auth="Container"
type="javax.sql.DataSource"
factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/testinfo?useUnicode=true&characterEncoding=gbk"
username="root"
password="luruibing"
maxActive="100"
maxIdle="30"
maxWait="10000" />
这样配置是可以运行,关键就是有时候会出现以下错误~~~我不知道原因~~请大家帮助一下~~谢谢你们~~~
错误信息是:
org.hibernate.exception.GenericJDBCException: could not execute query at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
at org.hibernate.loader.Loader.doQuery(Loader.java:390)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 34 more它说无法执行query方法,
但是有大部分不会出现这样的错,就是有时候在注册,或者登陆的时候出现,但是刷新就没有问题了
为什么会出现这样的问题??
这个错误的原因在那?
如果是配置问题,那么怎么还是可以运行?还是可以显示数据?
或者你们直接给我回复一个你们的数据源配置嘛~~~谢谢
我用的是tomcat 6.0 SSH MYSQL 5.0
解决方案 »
- 关于Servlet是什么?
- 用dom4j给xml添加一个跟节点和删除一个根节点
- jfreeChart的问题
- 新手求教,初学JSP出现HTTP Status 500错误,我用的是myeclipse连接oracle数据库
- [求助]部署EJB出现问题!麻烦哪位高手指点指点啊!先谢了!
- service的问题
- J2EE1.3只有17M,而J2EE1.4却有90M,下载过1.4版的,1.4版中多了什么,怎么那么大?
- java老手来教教我这个新手
- 进程线程分别可被分配多大内容
- 通过html页面的表单提交中文数据,Java后台出现乱码。跪求大神解答。
- Java面试宝典
- 用jquery在页面取action中的值(struts2)?
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost/oa" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>