thin 和 oci两种方法连接oracle数据库 比较

the JDBC thin driver provides the only way to access Oracle from the Web (applets). It is smaller and slower than the OCI drivers.

 

the JDBC oci driver :

One must have Net8 (SQL*Net) installed and working before attempting to use one of the OCI drivers.

从使用thin驱动切换到oci驱动在配置来说很简单,只需把连接字符串java:oracle:thin:@hostip:1521:实例名换为java:oracle:oci@本地服务名即可。如:

从 jdbc:oracle:thin:@10.1.1.2:1521:shdb 改成

jdbc:oracle:oci8:@shdb

//shdb具体查看network/admin/tnsnames.ora文件
 //有可能thin和oci两种方法的shdb是不一样的

public class TwoThread {

 public static void main(String[] args) {
  ThinThread thin = new ThinThread();
  OciThread oci = new OciThread();
  thin.start();
  oci.start();
 }
}

至于thin和oci的代码在此省略...

2个线程在各自的run函数里都是先进行数据库连接,然后在同一张表中插入50条数据

结果在thin线程刚开始插入第一条数据的时候(也就是连接刚成功),oci线程已经完成了30条的数据插入,之后几乎就是间隔的进行数据插入知道完成...

也就是说2着进行sql语句操作的效率目前还没有比较出来,但是光连接数据库这一步差别就已经很大了...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值