我是使用休眠连接的新手,在执行查询之前检查连接有困难。目前,如果我执行查询,我的 java swing 应用程序会在确认连接不可用之前挂起大约 30 秒。我已经使用了 session.isConnected() 但即使服务器关闭,返回总是正确的。请帮忙。谢谢
这是我的连接属性:
"hibernate.connection.provider_class", "org.hibernate.connection.C3P0ConnectionProvider"
"hibernate.c3p0.validate", "true"
"hibernate.c3p0.acquire_increment", "2"
"hibernate.c3p0.idle_test_period", "30"
"hibernate.c3p0.min_size", "5"
"hibernate.c3p0.max_size", "25"
"hibernate.c3p0.max_statements", "0"
"hibernate.c3p0.testConnectionOnCheckout", "true"
"hibernate.c3p0.testConnectionOnCheckIn", "true"
"hibernate.c3p0.preferredTestQuery", "SELECT 1"
"hibernate.c3p0.acquireRetryAttempts", "3"
"hibernate.c3p0.acquireRetryDelay", "200"
"hibernate.c3p0.timeout", "1000"
"hibernate.c3p0.maxConnectionAge", "1100"
"hibernate.connection.autoReconnect", "true"
"javax.persistence.lock.timeout", "1"
"javax.persistence.query.timeout", "1"