我得到以下异常在我的日志,当我尝试执行XA事务:异常与MS-SQL服务器,JDBC和XA事务
javax.transaction.xa.XAException: com.microsoft.sqlserver.jdbc_SQLServerException: failed to create the XA control connection. Error: "The EXECUTE permission was denied on the object 'xp_sqljdbc_xa_init_ex', database 'master' schema 'dbo'
我跟着这些教程Understanding XA Transactions和How to make MSSQL Server XA Datasource Work? 以下后第一个教程我也跑在SSMS以下命令:
use master GO
EXEC sp_addrolemember [SqlJDBCXAUser], 'MyUserName' GO
我还要补充一点,我跑
use master GO EXEC sp_grantdbaccess 'MyUserName','MyUserName' GO
验证用户是否有权访问主数据库,并且出现“用户已存在于当前数据库中”的错误。 最后,我通过SSMS验证了角色SqlJDBCXAUser
的确针对xp_sqljdbc_xa_init_ex
授予了EXECUTE。
我使用的数据库显然不是master
而是myDBName
。 关于这个问题,两者之间唯一的相互关系是MyUserName
是myDBName
的所有者,并以master
中的用户身份存在。
我的服务器正在Windows XP SP3上运行(所以第一个教程中提到的修补程序与XP SP2和以下版本无关,因为我试图运行此修补程序时知道此修补程序)。
有人遇到此问题?我真的很感激一些潜在客户。
谢谢,
以太
更新:
我已经看过了第一个教程,从Microsoft
,一次有两段这我不知道他们的意思,他们可能包含解决方案:
Execute the database script xa_install.sql on every SQL Server instance that will participate in distributed transactions. This script installs the extended stored procedures that are called by sqljdbc_xa.dll. These extended stored procedures implement distributed transaction and XA support for the Microsoft SQL Server JDBC Driver. You will need to run this script as an administrator of the SQL Server instance.
当他们说SQL Server instance
,做他们的意思是它包含几个数据库,包括master
和myDBName
在SQL Server(我已经习惯了甲骨文而言这是一个有点DIF ferent)?我运行xa_install.sql
脚本,因为它是给定的,它声明use master
。
这是第二段:
Configuring the User-Defined Roles
To grant permissions to a specific user to participate in distributed transactions with the JDBC driver, add the user to the SqlJDBCXAUser role. For example, use the following Transact-SQL code to add a user named 'shelby' (SQL standard login user named 'shelby') to the SqlJDBCXAUser role:
USE master
GO
EXEC sp_grantdbaccess 'shelby', 'shelby'
GO
EXEC sp_addrolemember [SqlJDBCXAUser], 'shelby'
SQL user-defined roles are defined per database. To create your own role for security purposes, you will have to define the role in each database, and add users in a per database manner. The SqlJDBCXAUser role is strictly defined in the master database because it is used to grant access to the SQL JDBC extended stored procedures that reside in master. You will have to first grant individual users access to master, and then grant them access to the SqlJDBCXAUser role while you are logged into the master database.
我不知道,但我认为上面的粗体句话说,SqlJDBCXAUser
角色只应在master
和其他被定义访问myDBName
的用户应被授予对master
的访问权限,然后添加到角色中,并且将以某种方式(不知道如何)在使用时启用它们数据库使用xa软件包。
更新2: 这是从存储过程中的安全设置SSMS下SqlJDBCXAUser作用
哇!这实际上工作!谢谢。奇怪的是,我执行了这些命令的变体(作为MS教程的一部分,它们是xa_install.sl的一部分),唯一的区别是我授予角色权限并将我的用户添加到角色。你知不知道为什么会发生这种情况?我会非常感激。 – Ittai 2010-11-06 12:35:38
这也适用于我,谢谢! - 我认为微软应该更新他们的文档,使他们更全面和更加傻瓜。 – monojohnny 2014-07-28 15:56:32