java - How to get given connection is xa or non xa for given data source? -
using code unable connection xa or non xa
databasemetadata dbmd = con.getmetadata(); dbmd.getdrivername(); system.out.println("drivername - "+dbmd.getdrivername()+"drivername class - "+dbmd.getdrivername().getclass() +"drivername class name - "+ dbmd.getdrivername().getclass().getname()); system.out.println("driverversion - "+dbmd.getdriverversion()); system.out.println("multipletransactions - "+dbmd.supportsmultipletransactions()); system.out.println("transactions - "+dbmd.supportstransactions()); system.out.println("getclassgetname - "+dbmd.getclass().getname()); system.out.println("classname"+(dbmd.getdrivername()).getclass().getname()); system.out.println("url - "+dbmd.geturl()+" getusername "+dbmd.getusername()); system.out.println("defaulttransactionisolation - "+dbmd.getdefaulttransactionisolation()+" connection "+dbmd.getconnection()+" connection class "+dbmd.getconnection().getclass()+" connection class name "+dbmd.getconnection().getclass().getname());
your question title says "given datasource". have access datasource object? code example shows have access connection.
assuming have access datasource object can do:
if(mydatasource instanceof javax.sql.xadatasource) system.out.println("xa datasource"); else{ try{ mydatasource.unwrap(javax.sql.xadatasource.class); system.out.println("xa datasource"); } catch(sqlexception sqle){ system.out.println("not xa datasource"); } }
Comments
Post a Comment