如何在创建DB2 JDBC连接属性后更改它?

时间:2014-08-12 16:53:08

标签: java jdbc properties

我在创建DB2连接之前设置ClientAccountingInformation属性,以便进行日志记录。

    this.properties.put("ClientAccountingInformation", "test");
    lDbConection = DriverManager.getConnection(this.connectionString, this.properties);

但是每次使用此连接时我都需要设置一个不同的值,因为它来自连接池,它被不同的事务重用。

事实上,我需要的是:

  • 创建连接
  • 使用值A
  • 设置属性
  • 使用连接
  • 将其返回连接池
  • 再次获取以进行其他交易
  • 使用值B
  • 设置属性
  • 使用连接
  • 将其返回连接池

等等......

1 个答案:

答案 0 :(得分:0)

这是可能的:

    properties.put("ClientAccountingInformation", "test 2");
    lDbConnection.setClientInfo(properties);