Hibernate3.5.1+Proxool0.9.1+Oracle10g2实现关键

紧急追加一个包在附件,Hibernate3.5.1实现还需要slf4j-nop-1.5.8.jar的支持。

1,Hibernate3.5.1中自带的Proxool版本是0.8.3。这个版本实现相对简单。与Proxool-0.9.1的区别在于jar包的增加,如果需要使用0.9.1则需要增加commons-logging.jar、proxool-cglib.jar两个包。
proxool-cglib.jar包在proxool下载文件中包含有。
最新proxool下载地址为:
http://ncu.dl.sourceforge.net/project/proxool/proxool/0.9.1/proxool-0.9.1.zip
commons-logging.jar包,我会上传到附件,以方便需要的朋友下载。

2,proxool.xml配置文件中,不能有注释代码,否则会报如下错误:
Exception in thread "main" org.hibernate.HibernateException: Proxool Provider unable to load JAXP configurator file: proxool.xml
Caused by: org.logicalcobwebs.proxool.ProxoolException: Parsing failed.
Caused by: org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.

3,proxool.xml配置文件的写法:
<?xml version="1.0" encoding="utf-8"?>
<something-else-entirely>
	<proxool>
		<alias>proxool</alias>
		<driver-url>jdbc:oracle:thin:@localhost:1521:xe</driver-url>
		<driver-class>oracle.jdbc.OracleDriver</driver-class>
		<driver-properties>
			<property name="user" value="scott" />
			<property name="password" value="12345678" />
		</driver-properties>
		<house-keeping-sleep-time>90000</house-keeping-sleep-time>
		<proxool.simultaneous-build-throttle>20</proxool.simultaneous-build-throttle>
		<prototype-count>5</prototype-count>
		<maximum-connection-count>100</maximum-connection-count>
		<minimum-connection-count>10</minimum-connection-count>
	</proxool>
</something-else-entirely>


4,hibernate.cfg.xml文件的写法:
<!DOCTYPE hibernate-configuration PUBLIC
	"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
	"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
	<session-factory name="foo">

		<property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
		<property name="hibernate.proxool.pool_alias">proxool</property>
		<property name="hibernate.proxool.xml">proxool.xml</property>

		<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
		<property name="hibernate.show_sql">true</property>

		<!--
			<property name="hibernate.hbm2ddl.auto">create</property>
		-->

		<mapping resource="domain/UserTest.hbm.xml" />
	</session-factory>
</hibernate-configuration>


5,不要试图让hibernate自动往Oracle里创建非法表名的表,如user表。
最后提供一个测试源码压缩包上传至附件,所需jar包,请自行添加。
hibernate-distribution-3.5.1-Final\lib\required目录下有。
good luck!

你可能感兴趣的:(oracle,Hibernate,xml,jdbc,单元测试)