WebSphere Application Server 傳統版和 Liberty 之間的配置差異:dataSource 和 jdbcDriver 元素
Liberty 中的 dataSource 與 WebSphere® Application Server 傳統版中的資料來源之間的配置存在一些差異。
- 不同名稱的資料來源內容
- ifxIFX_LOCK_MODE_WAIT,即 WebSphere Application Server 傳統版中的 informixLockModeWait。
- supplementalJDBCTrace,即 WebSphere Application Server 傳統版中的 supplementalTrace。
- transactional,即 WebSphere Application Server 傳統版中的 nonTransactionalDataSource。
- isolationLevel,即 WebSphere Application Server 傳統版中的 webSphereDefaultIsolationLevel。
- queryTimeout,即 WebSphere Application Server 傳統版中的 webSphereDefaultQueryTimeout。
- id,即 WebSphere Application Server 傳統版中的 name。
- 不同值的資料來源內容
- beginTranForResultSetScrollingAPIs,在 Liberty 中依預設為 true
- beginTranForVendorAPIs,在 Liberty 中依預設為 true
- connectionSharing,在 Liberty 中依預設為 MatchOriginalRequest
- statementCacheSize,即 WebSphere Application Server 傳統版中的 JDBC 提供者內容,Liberty 中的 dataSource 內容,其預設值為 10。
- WebSphere Application Server 傳統版中沒有 Liberty 對等項目的資料來源內容
- category
- supportsDynamicUpdates
- 資料來源的 connectionSharing 內容
- Liberty 容許將 connectionSharing 配置成 MatchOriginalRequest 或 MatchCurrentState。 依預設,它是 MatchOriginalRequest。
- WebSphere Application Server 傳統版容許以更精細的方式來配置 connectionSharing,其中個別的連線內容可以根據原始連線要求或現行連線狀態來進行比對。 在 WebSphere Application Server 傳統版中,connectionSharing 是位元組合,代表要根據現行連線狀態來比對的連線內容。 在 WebSphere Application Server 傳統版中,0 值表示要根據原始連線要求來比對所有內容。-1 值表示要根據現行連線狀態來比對所有內容。WebSphere Application Server 傳統版的預設值為 1,表示根據現行連線狀態來比對隔離層次。其他所有內容則是根據原始連線要求來比對。
- 資料來源的期間內容
您可以利用 Liberty 中的單位來選擇性指定期間內容。例如,
請參閱 Java 資料庫連線功能 4.1,以瞭解 dataSource 元素接受的時間單位和格式。 省略 Liberty 中的單位,相當於採用 WebSphere Application Server 傳統版中的預設單位。<dataSource id="informix" jndiName="jdbc/informix" queryTimeout="5m" ...> <properties.informix ifxIFX_LOCK_MODE_WAIT="120s" .../> </dataSource>
- JDBC 驅動程式配置
- 在 Liberty 中,對於具備 XA 功能及不具備 XA 功能的資料來源實作類別,您可以採用配置不同 jdbcDriver 元素的相同方式。另外,您也可以兩者都使用單一 jdbcDriver 元素。 定義多重 jdbcDriver 元素,不會導致使用不同的類別載入器。 在 Liberty 中,jdbcDriver 元素一律使用它們所配置之共用程式庫的類別載入器。
- 在WebSphere Application Server 傳統版中,JDBC 提供者定義成指向 JDBC 驅動程式 JAR、壓縮檔和原生檔案。 對於具備 XA 功能及不具備 XA 功能的資料來源實作類別,您必須分別定義其 JDBC 提供者。
對於某些常用的 JDBC 驅動程式,Liberty 會根據驅動程式 JAR 的名稱來推斷資料來源實作類別的名稱。因此,您可以省略實作類別名稱。 例如:<jdbcDriver id="Derby" libraryRef="DerbyLib"/> <library id="DerbyLib"> <fileset dir="C:/Drivers/derby" includes="derby.jar" /> </library>
請利用預設實作類別的選用內容來置換這些類別,例如 javax.sql.DataSource、javax.sql.ConnectionPoolDataSource 和 javax.sql.XADataSource。
置換 Liberty 選取的預設 javax.sql.XADataSource 和 javax.sql.ConnectionPoolDataSource 實作:
如需 jdbcDriver 元素的相關資訊,請參閱 Java 資料庫連線功能 4.1。<jdbcDriver id="Derby" libraryRef="DerbyLib" javax.sql.XADataSource="org.apache.derby.jdbc.EmbeddedXADataSource" javax.sql.ConnectionPoolDataSource="org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource"/> <library id="DerbyLib"> <fileset dir="C:/Drivers/derby" includes="derby.jar" /> </library>