开发者

How to set SQL Server Connection pool size

开发者 https://www.devze.com 2023-02-09 17:55 出处:网络
I am using Hibernate with a Java web application and I want to set the lim开发者_如何转开发it the SQL Server 2005 connection pool size. As far as I have read I have to use a connection string.

I am using Hibernate with a Java web application and I want to set the lim开发者_如何转开发it the SQL Server 2005 connection pool size. As far as I have read I have to use a connection string. Can I specify it in the hibernate.properties or in the hibernate.cfg.xml? Are there mandatory fields or can I just specify the Max Pool Size?

EDIT: I would like to reproduce an error that came from a production machine:

2011-02-07 17:52:00,282 ERROR [STDERR] [WARN] JDBCExceptionReporter - SQL Error: 0, SQLState: 08S01
2011-02-07 17:52:00,282 ERROR [STDERR] [ERROR] JDBCExceptionReporter - I/O Error: Connection reset by peer: socket write error
2011-02-07 17:52:00,282 ERROR [STDERR] [ERROR] JDBCTransaction - JDBC rollback failed <java.sql.SQLException: Invalid state, the Connection object is closed.>java.sql.SQLException: Invalid state, the Connection object is closed.
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen(ConnectionJDBC2.java:1634)
    at net.sourceforge.jtds.jdbc.ConnectionJDBC2.rollback(ConnectionJDBC2.java:2027)
    at org.hibernate.transaction.JDBCTransaction.rollbackAndResetAutoCommit(JDBCTransaction.java:183)
    at org.hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:162)


If you're using e.g., c3p0 you can configure pool size by maxPoolSize property, e.g.:

<bean id="datasource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="...." />
    <property name="jdbcUrl" value="..."/>
    <property name="maxPoolSize" value="..." />
</bean>
0

精彩评论

暂无评论...
验证码 换一张
取 消