- 标签:DRCP、Database Resident Connection Pooling、数据库驻留连接池
- 释义:DRCP(全称Database Resident Connection Pooling)数据库驻留连接池(Oracle自己的数据库连接池技术)
★ Oracle开启并配置DRCP
sqlplus / as sysdba
SQL > execute dbms_connection_pool.start_pool();
SQL > execute dbms_connection_pool.alter_param('','minsize','1');
SQL > execute dbms_connection_pool.alter_param('','maxsize','1');
重启生效
★ Java代码
package PAC_001;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.SQLException;
import oracle.jdbc.pool.OracleDataSource;
public class CLA_oracle {public static void main(String args[]) throws SQLException {OracleDataSource ods = null;Connection conn = null;Statement stmt = null;ResultSet rset = null;ods = new OracleDataSource();ods.setURL("jdbc:oracle:thin:@1.1.1.9:1521/prodpdb1:pooled");ods.setUser("zzt");ods.setPassword("zzt");conn = ods.getConnection();try {stmt = conn.createStatement();rset = stmt.executeQuery("SELECT count(*) FROM zzt.emp");while (rset.next())System.out.println(rset.getString(1));}finally {if (rset != null)rset.close();if (stmt != null)stmt.close();if (conn != null)conn.close();}}
}
※ 如果您觉得文章写的还不错, 别忘了在文末给作者点个赞哦 ~