ojdbc的jar包

在使用连接oracle数据库的时候尽量使用服务端E:\app\80953\product\11.2.0\dbhome_1\jdbc\lib下的jar包,否则可能会出错!

在JDK 1.6 中的注释

获取Connection的方式

1. DriverManager

Class.forName(driverClass);
Connection conn = DriverManager.getConnection(jdbcUrl, user, password);

2. DataSource

dataSource.getConnection();

DataSource的实现

1. 驱动自带

// Oracle
oracle.jdbc.pool.OracleDataSource

2. 连接池

// C3P0
com.mchange.v2.c3p0.ComboPooledDataSource <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency> // DBCP
org.apache.commons.dbcp2.BasicDataSource <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-dbcp2</artifactId>
<version>2.4.0</version>
</dependency> // Druid
com.alibaba.druid.pool.DruidDataSource <!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>

参考资料

05-11 22:26