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語句操作的效率目前還沒有比較出來,但是光連接數據庫這一步差別就已經很大了...