In web development, hibernate can be used to configure data sources, but in actual applications, multiple data sources may be connected.
1. Configure dataSource
<bean class=""> <property name="driverClassName"> <value></value> </property> <property name="url"> <value></value> </property> </bean>
2. Configure sessionFactory
<bean class="."> <property name="dataSource"> <ref local="dataSource"></ref> </property> <property name="hibernateProperties"> <props> <prop key=".provider_class"> .C3P0ConnectionProvider</prop> <!-- Whether it will be generated during the runtimeSQLOutput to log for debugging --> <prop key="hibernate.show_sql">true</prop> <!--Specify the language of the connection--> <prop key="dialect"> </prop> <!--Whether to collect statistics that contribute to performance adjustment--> <prop key="hibernate.generate_statistics">true</prop> <!--Whether to reconnect automatically--> <prop key="">true</prop> <!--Whether to automatically release the connection--> <prop key=".release_mode">auto</prop> <!--Cache configuration--> <prop key=".provider_class"> </prop> <prop key=".use_second_level_cache"> false </prop> <prop key=".use_query_cache">false</prop> </props> </property> <property name="mappingResources"> <list> <value>Mapping table</value> </list> </property> </bean>
3. Add jdbc support
<bean class=""> <property name="dataSource"> <ref bean="dataSourceLrsql"/> </property> </bean> <bean class=""> <property name="jdbcTemplate"> <ref bean="jdbcTemplatelr"/> </property> </bean>
Thank you for reading, I hope it can help you. Thank you for your support for this site!