您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
06-JdbcTemplate基本使用-spring产生模板对象代码实现(抽取jdbc.properties)
发布时间:2025-01-05 13:55:37编辑:雪饮阅读()
-
其实抽取jdbc.properties这在上篇中早已实现了的
那这里就贴一下Spring Config的配置文件xml吧:
<?xml version="1.0" encoding="UTF-8"?>
<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"/>
<bean id="dataSource" 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.username}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="buser1" class="com.User">
<property name="name" value="user1"/>
<property name="addr" value="shenzhen"/>
</bean>
<bean id="buser2" class="com.User">
<property name="name" value="user2"/>
<property name="addr" value="shanxi"/>
</bean>
<context:component-scan base-package="com.wzgy" />
</beans>
关键字词:JdbcTemplate,jdbc,properties,抽取
相关文章
- 05-JdbcTemplate基本使用-spring产生模板对象代码实现
- 03-JdbcTemplate基本使用-快速入门代码实现
- 07-Spring配置数据源-Spring(配置文件中)加载properti
- 05-Spring配置数据源-抽取jdbc.properties文件
- 12-JDBC练习-添加&修改&删除(基于executeUpdate增删改
- 06-JDBC-API详解-PreparedStatement-SQL注入演示
- 05-JDBC-API详解-ResultSet(结果集通过ResultSet遍历
- 04-JDBC-API详解-Statement(单元测试与执行语句的影响
- 03-JDBC-API详解-Connection(事务处理)
- 02-JDBC-API详解-DriverManager