我特别使用 hibernate.c3p0 和属性 idle_test_period , preferredTestQuery 和 timeout 来解决问题会话已关闭!!但是现在,我遇到了读取超时的问题,当我执行Web服务时,未返回响应。在的配置下> hibernate.cfg.xml 和配置mysql 数据库
List<string> mainList = new List<string>(new string[]
{
"bool",
"byte",
"char",
"decimal",
"double",
"float",
"int",
"long",
"sbyte",
"short",
"uint",
"ulong",
"ushort"
});
foreach (string item in mainList)
{
Console.WriteLine("Size of {0} : {1}", item, sizeof(ITEM_STRING_TO_TYPE));
// like this
Console.WriteLine("Size of int: {0}", sizeof(int));
}
我的数据库配置超时:
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://xxxxxx:xx/xx</property>
<property name="hibernate.connection.username">xxx</property>
<property name="hibernate.connection.password">xxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="show_sql">true</property>
<property name="use_sql_comments">true</property>
<property name="hibernate.c3p0.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">60</property>
<property name="hibernate.c3p0.max_size">50</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>