开发者

Dynamic database connection with iBatis

In my current project I am writing a service that receives configuration commands 'from above' and has to distribute those configurations to databases stored locally on the machines being configured.

The schema for the the configuration databases are identical, but the data is specific the machine it resides.

The number of machines may be changed at any time. I am currently using NHibernate to connect to the configuration databases, and are able to create these connections dynamically. (name of the machine is passed in with the configuration command)

NHibernate is not performing up to the project requirements. This may be due to the team's lack of experience with it, or the nature of the tool. In a static environmen开发者_StackOverflow中文版t, iBatis has done better, but all experience I have with ibatis requires the configuration of the datasources at build time, or in an xml file stored locally with the service(here the datasources were still built once at runtime)

It is not an option to hard code all the possible machines.

Is it possible with iBatis, to dynamically construct the datasource using predefined sqlmaps and the input of the url to be used?

Essentially the same question left unanswered elsewhere years ago (d) and (e) of his 'Additional requirements' to not match my scenario.

Ideally I would be able to:

  • Do the overhead of constructing a datasource once.
  • Reuse the same datasource by closing the connection, and reopening it with a different url.
  • Have a pool of connections using the same configuration simultaneously.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜