[当将JBoss的XA数据源中的IntegratedSecurity设置为true时,Microsoft的JDBC驱动程序不会将'true'设置解析为布尔值,但是会引发错误:
java.lang.NoSuchMethodException:
com.microsoft.sqlserver.jdbc.SQLServerXADataSource.setIntegratedSecurity(java.lang.String)
这只是使用XA数据源时的问题,非XA数据源在集成安全性下正常工作。
还有其他方法可以为JBoss上的XA连接设置集成安全性,还是在设置xa-datasource-property时告诉它发送布尔值的方法?
要重现此行为:
a)在JBoss AS configuration \ standalone \ standalone.xml中,向JNDI添加一个新的xa-datasource:
<xa-datasource jta="true" jndi-name="java:jboss/datasources/jndiName" pool-name="poolName" enabled="true" use-java-context="true" use-ccm="true">
<xa-datasource-property name="ServerName">
localhost
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
MyDbName
</xa-datasource-property>
<xa-datasource-property name="SelectMethod">
cursor
</xa-datasource-property>
<!-- this should work but doesn't -->
<xa-datasource-property name="IntegratedSecurity">
true
</xa-datasource-property>
<xa-datasource-class>com.microsoft.sqlserver.jdbc.SQLServerXADataSource</xa-datasource-class>
<driver>sqljdbc</driver>
<xa-pool>
<is-same-rm-override>false</is-same-rm-override>
</xa-pool>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker"/>
</validation>
</xa-datasource>
b)重新启动JBoss AS
c)尝试使用已配置的JNDI连接执行查询:
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup("java:jboss/datasources/jndiName");
Connection conn = null;
try {
conn = ds.getConnection();
// try to execute something
CallableStatement stmt = conn.prepareCall("{? = call some_stored_procedure()}");
stmt.execute();
} finally {
if (conn != null)
conn.close();
}
执行此代码将导致异常说明:
java.lang.NoSuchMethodException:
com.microsoft.sqlserver.jdbc.SQLServerXADataSource.setIntegratedSecurity(java.lang.String)
我也遇到过这个问题,但是如果使用URL xa-datasource-property,我可以使它正常工作。
示例:
<xa-datasource-property name="URL">jdbc:sqlserver://<host>:<port>;database=<db>;integratedSecurity=true</xa-datasource-property>
这些片段需要删除:
<xa-datasource-property name="ServerName">
localhost
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
MyDbName
</xa-datasource-property>
<xa-datasource-property name="SelectMethod">
cursor
</xa-datasource-property>
<!-- this should work but doesn't -->
<xa-datasource-property name="IntegratedSecurity">
true
</xa-datasource-property>