zoukankan      html  css  js  c++  java
  • spring常见引入数据源的几种方式

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">





    <!--引入外部属性文件-->
    <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
    <!--c3p0 数据源-->
    <bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="${jdbc.driver}"></property>
    <property name="jdbcUrl" value="${jdbc.url}"></property>
    <property name="user" value="${jdbc.user}"></property>
    <property name="password" value="${jdbc.password}"></property>
    </bean>
    <!--dbcp 数据源-->
    <bean id="dbcpDatSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="${jdbc.driver}"></property>
    <property name="url" value="${jdbc.url}"></property>
    <property name="username" value="${jdbc.user}"></property>
    <property name="password" value="${jdbc.password}"></property>
    </bean>
    <!--spring自带 数据源-->
    <bean id="springDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driver}"></property>
    <property name="url" value="${jdbc.url}"></property>
    <property name="username" value="${jdbc.user}"></property>
    <property name="password" value="${jdbc.password}"></property>
    </bean>
    <!--创建jdbc 模板-->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource" ref="springDataSource"></property>
    </bean>
    </beans>
  • 相关阅读:
    如何自定义iOS中的控件
    NSArray中的对象进行排序
    微信摇动代码
    思考面向对象
    网络编程 socket编程
    iOS RUN LOOP 是个什么东西?
    iOS runloop 自定义输入源
    iPhone开发资源汇总
    UISearchBar
    重学STM32---(八)----SDIO
  • 原文地址:https://www.cnblogs.com/dragonyl/p/11153320.html
Copyright © 2011-2022 走看看