最近的一個項目中,由於界面查詢的數據量比較大,關聯的表比較多,有些數據查出來需要臨時保存起來供後面的查詢使用,於是想到了用oracle的臨時表來實現這個需求。大家都知道,oracle的臨時表有兩種:事務級別臨時表和會話級別臨時表,我這裡使用的是會話級別的臨時表。當時把功能時候後就以為萬事大吉了,沒想 ...
最近的一個項目中,由於界面查詢的數據量比較大,關聯的表比較多,有些數據查出來需要臨時保存起來供後面的查詢使用,於是想到了用oracle的臨時表來實現這個需求。大家都知道,oracle的臨時表有兩種:事務級別臨時表和會話級別臨時表,我這裡使用的是會話級別的臨時表。當時把功能時候後就以為萬事大吉了,沒想到就在這裡買下了一個坑。
坑的浮現:之後在為系統加調試日誌時偶然發現了臨時表的數據沒有像oracle臨時表的定義那樣“不同會話獨享臨時表,臨時表的數據在會話結束後被自動清空”。首先看第一次查詢的日誌記錄截圖,第一次的查詢數據量是10017行,紅色框圈住的地方使用到臨時表:




Open()
method is invoked. In this case, a new connection is established.
Connection調用Close()方法時,以下是oracle官方文檔描述:
Rolls back any pending transactions.
Places the connection to the connection pool if connection pooling is enabled. Even if connection pooling is enabled, the connection can be closed if it exceeds the connection lifetime specified in the connection string. If connection pooling is disabled, the connection is closed.
Closes the connection to the database.
The connection can be reopened using Open()
.