http://log-cd.iteye.com/blog/199482
1、Hiebernate配置文件中引用proxool配置文件:
<hibernate-configuration> <session-factory> <property name="proxool.pool_alias">DBPool</property> <property name="proxool.xml">proxool.xml</property> <property name="connection.provider_class"> org.hibernate.connection.ProxoolConnectionProvider </property> <property name="show_sql">true</property> <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property> </session-factory> </hibernate-configuration>
2、直接在spring配置文件中配置proxool,无proxool.xml配置文件
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource" destroy- method="reset"> <property name="driver" value="com.mysql.jdbc.Driver" /> <property name="driverUrl" value="jdbc:mysql://localhost/activemq? user=root&password=root" /><!--必须在这里配置用户名/密码,下面的貌似没用--> <property name="user" value="root" /> <property name="password" value="root" /> <property name="alias" value="jms1" /> <property name="houseKeepingSleepTime" value="90000" /> <property name="prototypeCount" value="5" /> <property name="maximumConnectionCount" value="100" /> <property name="minimumConnectionCount" value="10" /> </bean>
3、spring配置文件中直接配置Hibernate,引用proxool配置文件,无需Hibernate.xml
1 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> 2 <property name="hibernateProperties"> 3 <props> 4 <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop> 5 <prop key="hibernate.show_sql">true</prop> 6 <prop key="hibernate.cglib.use_reflection_optimizer">true</prop> 7 <prop 8 9 key="connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</prop> 10 <prop key="hibernate.proxool.xml">proxool.xml</prop> 11 <prop key="hibernate.proxool.pool_alias">DBPool</prop> 12 13 </props> 14 </property> 15 ............. 16 </bean>
4、spring配置文件中引用proxool配置文件,spring配置文件中直接配置Hibernate
http://blog.csdn.net/xingfeng0501/article/details/7475050
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>org.logicalcobwebs.proxool.ProxoolDriver</value> </property> <property name="url"> <value>proxool.db</value> </property> </bean> <bean id="sessionFactory" lazy-init ="true" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <!-- 依赖注入数据源,注入正是上文定义的dataSource--> <property name="dataSource"><ref local="dataSource"/></property> <property name="lobHandler" ref="lobHandler"/> <property name="mappingLocations"> <list> <!--以下用来列出所有的PO映射文件--> <value>classpath:xxx/xxx/xxx/xx/xxx.hbm.xml</value> </list> </property> <!--定义Hibernate的SessionFactory的属性 --> <property name="hibernateProperties"> <props> <!-- 指定Hibernate的连接方言--> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <!-- 不同数据库连接,启动时选择create,update,create-drop --> <prop key="hibernate.hbm2ddl.auto">update</prop> <prop key="hibernate.show_sql">false</prop> <prop key="connection.useUnicode">true</prop> <prop key="connection.characterEncoding">UTF-8</prop> </props> </property> </bean>
5、结合以上2和3的方式,在spring配置文件中直接配置Hibernate和proxool,无需Hibernate.xml和proxool.xml配置文件。(这种方式纯属以上方式的总结,未实践)
proxool详细配置:https://www.2cto.com/database/201110/109272.html
//获得数据库连接的语句
Connection conn=DriverManager.getConnection("proxool.dbname");