首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

使用Hibernate与MySQL时遇到的一个有关问题,记录上来

2012-11-03 
使用Hibernate与MySQL时遇到的一个问题,记录下来.1.错误描述:警告: SQL Error: 0, SQLState: 08S012009-4-

使用Hibernate与MySQL时遇到的一个问题,记录下来.
1.错误描述:
警告: SQL Error: 0, SQLState: 08S01
2009-4-13 16:21:23 org.hibernate.util.JDBCExceptionReporter logExceptions
严重: The driver was unable to create a connection due to an inability to establish the client portion of a socket.
This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable.
For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.
For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).
2009-4-13 16:21:23 org.hibernate.util.JDBCExceptionReporter logExceptions

2.解决方案:
上述问题是在大批量插入数据的情况下出现的,使用的数据源配置如下:

<bean id="dataSource"     name="code"><bean id="dataSource"class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close"><property name="driverClass"><value>com.mysql.jdbc.Driver</value></property><property name="jdbcUrl"><value>jdbc:mysql://localhost:3306/test</value></property><property name="properties"><props><prop key="c3p0.minPoolSize">2</prop><prop key="c3p0.maxPoolSize">50</prop><prop key="c3p0.timeout">5000</prop><prop key="c3p0.max_statement">100</prop><prop key="c3p0.testConnectionOnCheckout">true</prop><prop key="user">root</prop><prop key="password">123456</prop></props></property></bean>

至于更深层的原因,有时间继续研究,有新的结果再继续和大家讨论. 1 楼 魔力猫咪 2009-04-13   很正常。因为“DriverManagerDataSource并没有提供连接池的功能,只能作简单的连接测试”。也就是说其实它就是一个JDBC连接,但是表现成一个数据源让你用来测试的。记住下次选Spring组件的时候多看一下说明书。 2 楼 kim_miao 2009-04-14   魔力猫咪 写道
很正常。因为“DriverManagerDataSource并没有提供连接池的功能,只能作简单的连接测试”。也就是说其实它就是一个JDBC连接,但是表现成一个数据源让你用来测试的。记住下次选Spring组件的时候多看一下说明书。

多谢指导!

热点排行