共同依赖spring-jdbc:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
PostgreSql连接:
jdbc.driverClassName=org.postgresql.Driver
jdbc.url=jdbc:postgresql://localhost:5432/test_db?useUnicode=true&characterEncoding=utf-8
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
Mysql连接:
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/test_db?useUnicode=true&characterEncoding=utf-8
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
Oracle连接:
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:test_db?useUnicode=true&characterEncoding=utf-8
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.1.0</version>
</dependency>
SqlServer连接:
jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.url=jdbc:sqlserver://localhost:1433; DatabaseName=test_db?useUnicode=true&characterEncoding=utf-8
嵌入式数据库H2(用于测试):
jdbc.driverClassName=org.h2.Driver
jdbc.url=jdbc:h2:mem:test_db;DB_CLOSE_DELAY=-1;MODE=Mysql;TRACE_LEVEL_SYSTEM_OUT=2
<dependency><groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.184</version>
</dependency>