• Spring(Bean)4 配置数据源、连接池


    <!-- 配置数据源 Mysql
    c3p0: 连接池.

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    注入值 基本信息(必须要有的)
    <property name="user" value="root"></property>
    <property name="password" value="1234"></property>
    <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/test"></property>
    <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
    
    
    <property name="initialPoolSize" value="5"></property>
    <property name="maxPoolSize" value="10"></property>
    </bean> 

    -->

    <!-- 引用外部化的配置文件

    <context:property-placeholder location="classpath:db.properties"/> 
    jdbc.password=1234
    jdbc.url=jdbc:mysql://localhost:3306/test
    jdbc.driver=com.mysql.jdbc.Driver
    jdbc.initPoolSize=5
    jdbc.maxPoolSize=10

    -->


    <!-- 配置数据源 使用外部化的配置文件 -->

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="user" value="${jdbc.user}"></property>
    <property name="password" value="${jdbc.password}"></property>
    <property name="jdbcUrl" value="${jdbc.url}"></property>
    <property name="driverClass" value="${jdbc.driver}"></property>
    <property name="initialPoolSize" value="${jdbc.initPoolSize}"></property>
    <property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property>
    
    </bean>

    <!-- 配置数据源
    c3p0: 连接池. -->

    <!-- <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> -->
    <!-- <property name="user" value="USER_RZCLOUD"></property> -->
    <!-- <property name="password" value="Richway1"></property> -->
    <!-- <property name="jdbcUrl" value="jdbc:oracle:thin:@localhost/orcl"></property> -->
    <!-- <property name="driverClass" value="oracle.jdbc.driver.OracleDriver"></property> -->
    <!-- <property name="initialPoolSize" value="5"></property> -->
    <!-- <property name="maxPoolSize" value="10"></property> -->
    <!-- </bean> -->



    <!-- 引入外部文件

    <context:property-placeholder location="classpath:db.properties" />
    jdbc.user = USER_RZCLOUD
    jdbc.password = Richway1
    jdbc.url = jdbc:oracle:thin:@localhost/orcl
    jdbc.driver = oracle.jdbc.driver.OracleDriver
    jdbc.initPoolSize=5
    jdbc.maxPoolSize=10
    
    -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="user" value="${jdbc.user}"></property>
    <property name="password" value="${jdbc.password}"></property>
    <property name="jdbcUrl" value="${jdbc.url}"></property>
    <property name="driverClass" value="${jdbc.driver}"></property>
    <property name="initialPoolSize" value="${jdbc.initPoolSize}"></property>
    <property name="maxPoolSize" value="${jdbc.maxPoolSize}"></property>
    </bean>
  • 相关阅读:
    Weblogic 部署注意事项
    Can't load IA 32-bit .dll on a AMD 64-bit platform
    getDeclaredFields()和getFields()
    EJB QI查询
    Git for windows 中文乱码解决方案
    gulp browser-sync自动刷新插件
    input默认提示取消
    devDependencies和dependencies的区别
    npm安装插件提示
    gulp.watch监听文件
  • 原文地址:https://www.cnblogs.com/JinXinYuan/p/10535569.html
Copyright © 2020-2023  润新知