1

This is a peculiar issue:

Our Websphere administrator made a script error in creating datasource and that created our datasource without the attribute xa=”true” in the resources.xml file. The datasource is not created using WAS UI, but created with jython script.

Here is the xml snippet from resources.xml

<resources.jdbc:JDBCProvider xmi:id="JDBCProvider_34335495940" name="Oracle JDBC Driver (XA)" description="Oracle JDBC Driver (XA)" providerType="Oracle JDBC Driver (XA)" isolatedClassLoader="false" implementationClassName="oracle.jdbc.xa.client.OracleXADataSource" >
<classpath>${ORACLE_JDBC_DRIVER_PATH}/ojdbc7.jar</classpath>

Ideally the resources.xml file should have been like this (with xa attribute at the end)

<resources.jdbc:JDBCProvider xmi:id="JDBCProvider_1518484995940" name="Oracle JDBC Driver (XA)" description="Oracle JDBC Driver (XA)" providerType="Oracle JDBC Driver (XA)" isolatedClassLoader="false" implementationClassName="oracle.jdbc.xa.client.OracleXADataSource" **xa="true"**>
        <classpath>${ORACLE_JDBC_DRIVER_PATH}/ojdbc7.jar</classpath>

The application works all fine in Production without any issues.

The question is if we don’t provide the 'xa' attribute in the JDBC provider what would it understand the connection as?

The driver implementation class is: oracle.jdbc.xa.client.OracleXADataSource The connection methods are both XA getXAConnection() getXAConnection(java.lang.String userName, java.lang.String passwd)

so when WebSphere gets a connection at runtime, it should by default be an XA connection?

I have also checked and confirmed with the DBA that the database is enabled for XA.

Is the attribute xa=”true” required? If not provided, the default value becomes “false”?

Appreciate for your help!!

SPL
  • 11
  • 2

1 Answers1

0

My understanding of xa=true/false is that it helps to clarify which data source interface type is wanted (javax.sql.XADataSource which is xa capable vs javax.sql.ConnectionPoolDataSource which is not xa capable) in cases where the JDBC vendor provides a data source class that simultaneously implements both interfaces. In cases where the JDBC vendor only implements one of the interfaces, which we assume is the case for oracle.jdbc.xa.client.OracleXADataSource which you are using, the application server is able to figure out that you really wanted javax.sql.XADataSource because it is the only interface implemented by that class. Given that javax.sql.XADataSource only creates java.sql.XAConnection, in your case you would always end up using XAConnection which is two-phase commit capable.

As to whether or not the xa attribute is required, I would reply that you should always include it both for clarity and for consistency with the WAS UI, and also to protect against the somewhat unlikely possibility that a JDBC vendor, in a future version of their driver, could update their data source implementation to implement both interfaces, in which case the xa=true attribute would be needed to distinguish.

njr
  • 3,399
  • 9
  • 7
  • Thank you for the response, i found this on IBM site, but it does not specify what is the default value for the attribute though, https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/rxml_7adminjdbc.html#rxml_7adminjdbc__scr3 xa: Possible values are true and false. If set to true, data sources for the provider produce connections that applications use in two-phase commit, global transactions. If set to false, the data sources produce connections that applications use in single-phase commit, local transactions. – SPL Sep 26 '18 at 14:57
  • @ this site: https://www.ibm.com/support/knowledgecenter/en/SSMKHH_9.0.0/com.ibm.etools.mft.doc/ah61310_.htm jdbcProviderXASupport. An optional property that controls whether the broker connects to a database server using the XA Protocol. By default this property is set to true. If the database server is not enabled for XA Support, or coordinated transactions are not required, set the value to false. In which case the type 4 driver specified using the type4DriverClassName property is used, instead of the type 4 datasource specified in the type4DatasourceClassName property. – SPL Sep 26 '18 at 17:01
  • Please note that the link you provided above is a different IBM product, presumably one that is built on top of WebSphere Application Server, but the jdbcProviderXASupport attribute that it provides is an attribute of that product. Its value might be used to determine how they set the xa=true/false attribute on the JDBCProvider, but the default they document is their default for jdbcProviderXASupport, which doesn't necessarily need to be the same as the WebSphere Application Server default for the xa attribute. I still recommend being safe and explicitly specifying the value you require. – njr Sep 26 '18 at 21:10