1 , 首先查找JBOSS目录,找到 mysql-ds.xml文件,在其基础上进行修改
1.<datasources>
2. <local-tx-datasource>
3. <jndi-name>KylinDataSource</jndi-name>
4. <use-java-context>false</use-java-context>
5. <connection-url>jdbc:mysql://127.0.0.1:3306/kylin?useUnicode=true&characterEncoding=utf-8</connection-url>
6. <driver-class>com.mysql.jdbc.Driver</driver-class>
7. <user-name>alibaba</user-name>
8. <password>ca</password>
9. <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
10. <!-- should only be used on drivers after 3.22.1 with "ping" support
11. <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
12. -->
13. <!-- sql to call when connection is created
14. <new-connection-sql>some arbitrary sql</new-connection-sql>
15. -->
16. <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
17. <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
18. -->
19. <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
20. <metadata>
21. <type-mapping>mySQL</type-mapping>
22. </metadata>
23. </local-tx-datasource>
24.</datasources>
这里要注意的是<use-java-context></use-java-context>false , 这个属性设置为false时,程序中可以直接通过如下spring的JNDI访问 , 否则设置为true时候,JBOSS生成的JNDI,需要通过java:MYSQL才能访问,这里我郁闷了很久
2 , 设置 standardjaws.xml
1.<jaws>
2. <datasource>java:/KylinDataSource</datasource>
3. <type-mapping>mySQL</type-mapping>
4. <debug>false</debug>
3, 设置 standardjbosscmp-jdbc.xml
1.<jbosscmp-jdbc>
2.
3. <defaults>
4. <datasource>java:/KylinDataSource</datasource>
5. <datasource-mapping>mySQL</datasource-mapping>
4 , 设置 login-config.xml
1. <application-policy name="jbossmq">
2. <authentication>
3. <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
4. <module-option name="unauthenticatedIdentity">guest</module-option>
5. <module-option name="dsJndiName">java:/KylinDataSource</module-option>
6. <module-option name="principalsQuery">SELECT PASSWD FROM JMS_USERS WHERE USERID=?</module-option>
7. <module-option name="rolesQuery">SELECT ROLEID, 'Roles' FROM JMS_ROLES WHERE USERID=?</module-option>
8. </login-module>
9. </authentication>
10. </application-policy>
11.
12.
13.<application-policy name="HsqlDbRealm">
14. <authentication>
15. <login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
16. <module-option name="principal">sa</module-option>
17. <module-option name="userName">sa</module-option>
18. <module-option name="password"></module-option>
19. <module-option name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=KylinDataSource</module-option>
20. </login-module>
21. </authentication>
22. </application-policy>
注意这里的 name = KylinDataSource 必须设置成根上面两个文件的一样
4 , 修改 deploy/jms/ 目录下的 hsqldb-jdbc-state-service.xml
1.<depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=KylinDataSource</depends>
设置这里的depends依赖服务, 这里的name 还是使用 KylinDataSource,保持统一, 可根据情况作修改,最后改名为
mysql-jdbc-state-service.xml即可
5 , 搜索mysql-jdbc2-service.xml 替换原先得 hsqldb-jdbc2-service.xml
ok 完成了
时间: 2024-09-15 23:36:05