使用 Hibernate 从两个不同的 Web 应用程序 (GXT) 连接相同的数据库

发布于 2024-09-24 03:23:35 字数 166 浏览 3 评论 0原文

我正在使用基于 GXT 构建的两个不同的 Web 应用程序。但问题是,两个应用程序都访问同一个数据库,而当我们尝试在 Apache Tomcat 中一起部署然后同时访问它们时,hibernate 不允许这样做。您能告诉我如何使用两个应用程序中的 hibernate 访问同一个数据库吗?我们为此使用 c3p0 连接池。

I am working with two different web applications built upon GXT. But the problem is that both the applications are accessing the same database and the hibernate is not allowing to do so when we tried to deploy together in Apache Tomcat and then access them simultaneously. Can you tell me how can we access the same database using hibernate from both the applications? We are using c3p0 connection pool for this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风尘浪孓 2024-10-01 03:23:35

(...) 当我们尝试在 Apache Tomcat 中一起部署然后同时访问它们时,Hibernate 不允许这样做。

问题出在哪里?你得到了什么错误?提供一些详细信息可能有助于获得答案。

您能告诉我如何使用两个应用程序中的 hibernate 访问同一个数据库吗?我们为此使用 c3p0 连接池。

就这样做吧,我在这里没有看到任何阻碍(这就是为什么回答上述问题会有所帮助)。在不同的 JVM 中实例化多个 SessionFactory 实际上是一种非常常见的场景(例如,在集群上运行单个应用程序时,这在技术上与您的场景等效)。

(...) Hibernate is not allowing to do so when we tried to deploy together in Apache Tomcat and then access them simultaneously.

And what was the problem? What error did you get? Provide some details might help to get an answer.

Can you tell me how can we access the same database using hibernate from both the applications? We are using c3p0 connection pool for this.

Just do it, I don't see anything blocking here (which is why answering the mentioned questions will help). Instantiating several SessionFactory in different JVMs is actually a very common scenario (e.g. when running a single application on a cluster, which is technically equivalent to your scenario).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文