Java SQL Server 2008 Hibernate 4.1中的频繁读取超时
sql server 2008r2和hibernate面临一个奇怪的问题。经常从数据库获取读取超时错误,以下是错误详细信息:Java SQL Server 2008 Hibernate 4.1中的频繁读取超时,java,sql,sql-server,hibernate,amazon-web-services,Java,Sql,Sql Server,Hibernate,Amazon Web Services,sql server 2008r2和hibernate面临一个奇怪的问题。经常从数据库获取读取超时错误,以下是错误详细信息: 10:02:11,368 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/55.2.0.180:443-36) SQL Error: 0, SQLState: 08S01 10:02:11,368 ERROR [org.hibernate.engine.jdbc.spi.Sql
10:02:11,368 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/55.2.0.180:443-36) SQL Error: 0, SQLState: 08S01
10:02:11,368 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/55.2.0.180:443-36) Read timed out
10:02:11,368 ERROR [stderr] (http-/55.2.0.180:443-36) org.hibernate.exception.JDBCConnectionException: Read timed out10:02:11,368 ERROR [stderr] (http-/55.2.0.180:443-36) at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131)10:02:11,368 ERROR [stderr] (http-/55.2.0.180:443-36)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)10:02:11,368 ERROR [stderr] (http-/55.2.0.180:443-36)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)10:02:11,368 ERROR [stderr] (http-/55.2.0.180:443-36)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)10:02:11,384 ERROR [stderr] (http-/55.2.0.180:443-36)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)10:02:11,384 ERROR [stderr] (http-/55.2.0.180:443-36)
... 131 more10:02:11,727 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/55.2.0.180:443-36) SQL Error: 0, SQLState: null
10:02:11,727 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http-/55.2.0.180:443-36) The connection is closed.
10:02:11,727 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/CastrolCubedUnit].[spring]] (http-/55.2.0.180:443-36) JBWEB000236: Servlet.service() for servlet spring threw exception: com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
如果相关,则没有更多信息:
非常感谢我们的帮助 MS SQl server保留所有查询的统计信息。table
sys.dm_exec_query_stats
包含关于每个查询的统计信息,但在此之前,我建议您运行DBCC命令,该命令重新开始记录查询运行时间,并完成一些缓存清除工作
DNDC命令DBCC FREEPROCCACHE
下面是查找长查询的查询
SELECT DISTINCT TOP 10
t.TEXT QueryName,
s.execution_count AS ExecutionCount,
s.max_elapsed_time AS MaxElapsedTime,
ISNULL(s.total_elapsed_time / s.execution_count, 0) AS AvgElapsedTime,
s.creation_time AS LogCreatedOn,
ISNULL(s.execution_count / DATEDIFF(s, s.creation_time, GETDATE()), 0) AS FrequencyPerSec
FROM sys.dm_exec_query_stats s
CROSS APPLY sys.dm_exec_sql_text( s.sql_handle ) t
ORDER BY
s.max_elapsed_time DESC
GO
您可以对查询进行优化。对于每个查询,您都会收到此消息?您能够远程登录到DB服务器吗?不是每个查询,但一旦开始收到此错误,我们就会经常收到此消息。是的,telnet工作正常。c3p0设置文件中的超时设置是什么?还有,有没有什么问题需要花更多的时间来解决呢?我不这么认为。。这是我们的Hibrate设置和c3p0设置