1 /** SECTION END: CLEANUP **/2 3 /* Don't delete the following line. This is where sp_jdbc_getxacoordinator gets inserted. */4 /*** ADDPOINT_JTA ***/5 /*
6 ** JDBC 2.0 extensions (JTA support)
7 **
8 ** SybDatabaseMetaData.getXACoordinatorType()
9 **
10 ** returns a resultset of the form:
11 ** TxnStyle (indicating which transaction coordinator is being used.
12 ** 0 means none.
13 **
14 ** RequiredRoles (indicates what role the user must have to use)
15 ** NULL means none.
16 **
17 ** Status (a bitmask of capabilities that the coordinator provides)
18 ** 0x00000001 - set if user has necessary role
19 ** 0x00000002 - set if txns can migrate among connections
20 ** 0x00000004 - set if multiple connections can participate in same txn simultaneously
21 **
22 ** UniqueID (a string which uniquely identifies this server)
23 */24 createproceduresp_jdbc_getxacoordinator25 as26 27 declare@txnMode int
28 declare@status int
29 declare@uniqueID varchar(12)30 declare@curvalue int
31 declare@sqlCurValue varchar(200)32 /* For 12.0 and higher, jConnect expects to use DTM001. */33 /* DTM001 is defined as 2 in SybDataSource.RMTYPE_ASE_XA_DTM. */34 /* Users must have dtm_tm_role to use DTM. */35 /* Next, determine whether or not user has */36 /* dtm_tm_role when setting the status bits. */37 /* Lastly, return the unique ID for this resource. */38 39 /* verify that the 15.0 server is configured for XA using DTM */40 41 select@sqlCurValue= 'select @curvalue=cur.value from master.dbo.syscurconfigs cur, master.dbo.sysconfigures conf
42 where conf.comment = ''enable DTM'' and cur.config = conf.config '
43 /* The columns syscurconfigs.instanceid is present only if server is in sdc mode'*/44 if(@@clustermode = 'shared disk cluster')45 begin46 select@sqlCurValue=@sqlCurValue+ 'and cur.instanceid=@@instanceid'
47 end48 49 execute(@sqlCurValue)50 51 if(@curvalue!= 0)52 begin53 /* verify that the 12.0 server is licensed for XA using DTM */54 if(license_enabled('ASE_DTM')= 1)55 begin56 select@txnMode= 2
57 end58 end59 else60 begin61 select@txnMode= 0
62 end63 64 /* now check for role permission */65 if(charindex('dtm_tm_role', show_role())!= 0)66 begin67 select@status= 7
68 end69 else70 begin71 select@status= 6
72 end73 74 /* return results and name the columns */75 select TxnStyle =@txnMode, RequiredRole = 'dtm_tm_role', Status =@status, UniqueID = @@nodeid
76
exec sp_procxmode 'sp_jdbc_getxacoordinator', 'AnyMode'
go
Grant Execute on sp_jdbc_getxacoordinator to public
go