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