数据库链接与 JDBC 数据源
假设 Java Web 应用程序有一个“主”数据库模式。然而,Web 应用程序需要使用另一种数据库模式。
使用 2 个 JDBC 数据源更好还是使用 1 个带有指向其他模式的数据库链接的 JDBC 数据源更好?
最小化数据源数量或数据库链接数量是更好的架构吗?
Suppose a Java web application has a "main" database schema. However, there is another database schema that the web application needs to utalize.
Is it better to use 2 JDBC datasources or 1 JDBC datasource with a database link to the other schema?
Is the better architecture to minimize the number of datasources or the number of database links?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,这将是我的评论,但后来我意识到你已经设置了一个“错误的替代问题”,建议只有 A 和 B 是答案,而实际上 C 存在。
C 是:
三个都具备。
数据库链接是否有巨大的开销?不是使用它,只是拥有它。或者您的项目中有数据源?如果您的项目包含 3 个数据源,它会压垮服务器吗?还是7?
有时您需要来自一个数据库的数据...
也许有时您只需要来自另一个数据库的数据...
也许有时您需要在两个数据库之间连接数据...
所有三个“连接”都可能对您有用。
但如果那些“可能”变成了“从不”,那么如果您确实愿意,可以删除其中一个。
Well that was going to be my comment but then I realized that you've setup a "False Alternative Problem" By suggesting that only A and B are answers when in fact C exists.
C is:
Have all three.
Is there some huge overhead to a database link? Not using it, just having it. Or having a datasource in your project? Would it crush a server if your project contained 3 datasources? or 7?
There are times when you you want data from one database...
Maybe there are times when you want data only from the other database...
Maybe there are times when you need to join data between the two...
All three 'connections' could be of use to you here.
But if those Maybe's turn into Never's, then you can remove one if you really want to.