gpt4 book ai didi

postgresql - WSO2 "Use Data Source Factory"JNDI 数据源的选项

转载 作者:行者123 更新时间:2023-11-29 12:19:26 26 4
gpt4 key购买 nike

配置数据源时,可以选中“公开为 JNDI 数据源”部分中的“使用数据源工厂”复选框。文档解释如下:

To make the datasource accessible from an external environment, you must use a data source factory. When this option is selected, a reference object will be created with the defined datasource properties. The data source factory will create the datasource instance based on the values of the reference object when accessing the datasource from an external environment. In the datasource configuration, this is set as follows: < jndiConfig useDataSourceFactory="true" >

但是我听起来完全不清楚。这里的“外部环境”可能是什么?

有人可以更详细地解释设置和取消设置复选框状态之间的实际区别吗?

我在自定义中介中使用这样的 JNDI 数据源连接到 Postgres9.3,看到的区别如下:

  • 复选框“打开”:没有发出事务标记(BEGIN/COMMIT/ROLLBACK),但新记录总是添加到数据库中,就像自动提交打开一样
  • 复选框“关闭”:不时添加新记录,隐式发出 BEGIN 和 ROLLBACK 语句(显示在 Postgres 日志中)

最佳答案

因此,此设置的效果是为每个请求它的中介实例化特定的连接池 (org.apache.tomcat.jdbc.pool.DataSource)。否则,所有中介都使用相同的连接池。

在我的例子中,问题的出现是因为连接设置在返回到池中后没有被清除。一些中介已经为一些连接设置了 autoCommit=false,这里的行为变得不确定:仍然具有默认设置的连接成功地将数据保存在 DB 中,而 autoCommit=false 的连接发出 BEGIN/ROLLBACK 语句(因此在 DB 中不保存任何内容)。

关于postgresql - WSO2 "Use Data Source Factory"JNDI 数据源的选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34228565/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com