Spring:JdbcTemplate的介绍

在看这篇博文之前可以先看一下以往的博文:地址

1.1JdbcTemplate概述

1.2JdbcTemplate对象的创建

1.3配置数据源

以前我们学习过c3p0和DBCP这两个数据源,如果想要使用这个数据源就必须要导入相应的jar包

1.3.1环境搭建

1.3.2编写Spring的配置文件

(1)配置C3p0数据源

(2)配置DBCP数据源

(3)配置Spring内置数据源

关于数据库的连接问题,我们同样可以把他配置在一个属性文件中

 

引入外部属性文件的方式

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
     <property name="location" value="classpath:jdbc.properties"/>
 </bean>

 

另一种方式

<context:property-placeholder location="classpath:jdbc.properties"/>

 

posted @ 2021-02-25 19:10  薄眠抛却陈年事。  阅读(55)  评论(0编辑  收藏  举报