使用spring2.5.6整合jdbc的基本配置
2013-04-13 09:25
375 查看
以下是使用spring2.5.6整合jdbc时,配置文件applicationContext.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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation=" http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean id="jdbcUserDAO" class="com.tarena.dao.impl.JdbcUserDAO">
<property name="dataSource" ref="myDataSource"></property>
</bean>
<!--以下的bean制定了所操作的数据库的相关信息 -->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="root"></property>
<property name="password" value=""></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql:///dangdang"></property>
<property name="maxActive" value="15"></property>
<property name="initialSize" value="2"></property>
</bean>
</beans>
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation=" http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean id="jdbcUserDAO" class="com.tarena.dao.impl.JdbcUserDAO">
<property name="dataSource" ref="myDataSource"></property>
</bean>
<!--以下的bean制定了所操作的数据库的相关信息 -->
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="root"></property>
<property name="password" value=""></property>
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql:///dangdang"></property>
<property name="maxActive" value="15"></property>
<property name="initialSize" value="2"></property>
</bean>
</beans>
相关文章推荐
- 整合一下深度学习caffe环境配置和基本使用例程(CPU+GPU)
- spring jdbc --注:c3p0数据库连接池或druid连接池使用配置整理
- windows环境下 springMVC+jdbc+redis整合配置
- 浅谈spring+springMVC+mybatis框架整合(配置文件的使用)
- Spring+MyBatis整合使用MapperFactoryBean注入映射器(简化配置)
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- solr环境搭建&基本使用 - 程序灵感 solr服务与tomcat整合 solr使用配置步骤 solr使用 推荐分词工具 一.Solr服务与tomcat整合 1、solr
- [Spring3.x] 第 11 章 使用 Spring JDBC 访问数据库 & 第 12 章 整合其他 ORM 框架
- 关于spring boot整合mybatis使用oracle数据库出现could not load:oracle.jdbc.driver.OracleDriver问题的终极解决方案
- 如何使用Spring 配置各类(c3p0,dbcp,jndi)数据源以及jdbc
- 1,spring整合jdbc配置文件
- mybatis整合spring使用MapperScannerConfigurer配置问题
- SpringBoot学习笔记(7) SpringBoot整合Dubbo(使用yml配置)
- Spring整合Hibernate配置(使用hibernate.cfg.xml文件)
- Spring整合JUnit4测试,使用注解引入一个或多个配置文件
- Spring整合JUnit4测试时,使用注解引入多个配置文件
- ActiveMQ与Spring整合:(1)基本使用
- 【Spring】在Spring框架下使用注解配置JDBC事务
- Spring 使用配置文件读取jdbc.properties
- [Spring3.x] 第 11 章 使用 Spring JDBC 访问数据库 & 第 12 章 整合其他 ORM 框架