【问题标题】:How to create a postgresql xa datsource in wso2esb如何在 wso2esb 中创建 postgresql xa 数据源
【发布时间】:2018-10-07 22:24:29
【问题描述】:

如何管理 wso2esb 或 wso2dss 中的事务 我们可以选择在 wso2esb 中创建数据源。虽然我正在使用 xadatasource 创建外部数据源,但它无法创建我使用以下配置创建的问题

Data Source Type*=RDBMS
Name*=USCProduction
Data Source Provider*=External Data Source
Data Source Class Name*=org.postgresql.xa.PGXADataSource
Data Source Properties
====================
url=jdbc:postgresql://localhost:5432/USCProduction
user=admin
password=admin

但它无法创建这样的错误

ERROR: Error in creating external data source: org.postgresql.xa.PGXADataSource



ERROR - DataSourceRepository Error in creating external data source: org.postgresql.xa.PGXADataSource
org.wso2.carbon.ndatasource.common.DataSourceException: Error in creating external data source: org.postgresql.xa.PGXADataSource
    at org.wso2.carbon.ndatasource.rdbms.utils.RDBMSDataSourceUtils.handleExternalDataSource(RDBMSDataSourceUtils.java:323)
    at org.wso2.carbon.ndatasource.rdbms.utils.RDBMSDataSourceUtils.createPoolConfiguration(RDBMSDataSourceUtils.java:283)
    at org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource.<init>(RDBMSDataSource.java:42)
    at org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader.createDataSource(RDBMSDataSourceReader.java:58)
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.createDataSourceObject(DataSourceRepository.java:202)
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.registerDataSource(DataSourceRepository.java:359)
    at org.wso2.carbon.ndatasource.core.DataSourceRepository.addDataSource(DataSourceRepository.java:473)
    at org.wso2.carbon.ndatasource.core.services.NDataSourceAdminService.addDataSource(NDataSourceAdminService.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)

我们如何做到这一点并尝试将其复制到数据源文件中

<datasource>
            <name>sample</name>
  <xa-datasource jndi-name="java:jboss/PostgresXADS" pool-name="PostgresXADS">
    <driver>postgresql</driver>
    <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
    <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
    <xa-datasource-property name="DatabaseName">USCProduction</xa-datasource-property>
    <security>
      <user-name>admin</user-name>
      <password>admin</password>
    </security>
    <validation>
      <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker">
      </valid-connection-checker>
      <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter">
      </exception-sorter>
    </validation>
  </xa-datasource>
  <drivers>
    <driver name="postgresql" module="org.postgresql">
      <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
    </driver>
  </drivers>
</datasource>

如何在 wso2esb 中创建 xa 数据源以使用事务调解器

【问题讨论】:

    标签: wso2 datasource wso2esb wso2dss


    【解决方案1】:

    您需要将 PostgreSQL JDBC Driver 添加到 ESB_HOME/repository/components/lib,然后重启服务器。

    【讨论】:

    • 我已经在 lib 中添加了即使它给出错误 postgresql-9.0-801.jdbc4.jar 文件甚至给出错误
    • @faisal.shaik 您在使用 postgresql jar 时看到的错误是什么?我一直在使用 postgresql-9.3-1100.jdbc4.jar 没有任何问题。
    • 感谢回复我正在使用 9.1 postgres 并添加了 jar postgresql-9.0-801.jdbc4 这适用于默认数据源而不适用于 xa 数据源您是否做过任何事务示例请通过此链接stackoverflow.com/questions/21228546/… stackoverflow.com/questions/21135505/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    • 2019-06-19
    • 1970-01-01
    • 1970-01-01
    • 2019-01-09
    • 2011-12-18
    • 1970-01-01
    相关资源
    最近更新 更多