JNDI(Java Naming and Directory Interface)

JNDI 即 Java Naming and Directory Interface,中文叫Java命名和目录接口,是一组在Java应用中访问命名和目录服务的API。

DBCP和 C3p0 这两个是缓存的lib,一般和Hibernate等这样的中间件组合使用

JDBC 是JAVA连接数据库的组件,再加上驱动,就可以连接各种数据库。

ODBC 是WINDOWS平台的一个数据库连接标准,使用越来越少了。

 

基于spring 的profile功能 配置的 数据库连接xml配置:(正确与否还待验证O(∩_∩)O~)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="
           http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
           http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
           http://www.springframework.org/schema/jdbc    http://localhost:8080/schema/www.springframework.org/schema/jdbc/spring-jdbc.xsd
           http://www.springframework.org/schema/jee     http://localhost:8080/schema/www.springframework.org/schema/jee/spring-jee.xsd
       ">
       <!-- 开发数据源 -->
	<beans profile="development">
		<jdbc:embedded-database id="dataSource" type="H2">
		<jdbc:script location="classpath:conf/schema.sql"/>
		<jdbc:script location="classpath:conf/test-data.sql"/>
		</jdbc:embedded-database>
	</beans>
	<!-- 生产环境数据源 -->
	<beans profile="production">
		<jee:jndi-lookup 
			id="dataSource" jndi-name="/jdbc/SpitterDS"	resource-ref="true"/>
	</beans>

补充:embedded:嵌入式的数据源,在开发环境比较适合,其特点是每次重启应用运行测试的时候都能够重新填充测试数据。

profile功能 :就像开关一样 在较少改动代码的基础上灵活改变环境。以便项目的开发和生成环境分离

 

 

转载于:https://my.oschina.net/fivewang/blog/702775

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值