java 如何设置休眠以使用 Glassfish 连接池?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2508466/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 21:33:16  来源:igfitidea点击:

How to set up hibernate to use Glassfish connection pool?

javahibernateglassfish

提问by Jacob Schoen

I have set up a connection pool in Glassfish with a jndi resource for it also setup. I am stumped on how to configure hibernate to go get it.

我已经在 Glassfish 中设置了一个连接池,并为其设置了 jndi 资源。我很难过如何配置休眠来获取它。

I have come across alot of write ups to configure it to use C3P0 connection pool. Well I am lost. I found that I need to set:

我遇到了很多关于将其配置为使用 C3P0 连接池的文章。好吧,我迷路了。我发现我需要设置:

hibernate.connection.datasource
hibernate.jndi.url 
hibernate.jndi.class 
hibernate.connection.username
hibernate.connection.password
  • Would datasource be the same as the hibernate.connection.datasourceset in the connection pool?
  • What would hibernate.jndi.class be?
  • Are hibernate.connection.username and hibernate.connection.password for the connection to the database or to the appserver? I assume this is to the database, but why do I need them since that is all set in the appserver?
  • 数据源是否与hibernate.connection.datasource连接池中的集合相同?
  • hibernate.jndi.class 会是什么?
  • hibernate.connection.username 和 hibernate.connection.password 是否用于连接到数据库或应用程序服务器?我假设这是数据库,但为什么我需要它们,因为它们都在应用程序服务器中设置?

回答by vkraemer

This article about hibernate basicsseems to have the info you will want. Search for the string 'Using a JNDI DataSource'. Listing 2 is important. You may want to compare it against listing 1...

条关于Hibernate基础知识似乎有你会想要的信息。搜索字符串“使用 JNDI 数据源”。清单 2 很重要。您可能想将其与清单 1 进行比较...

It looks like you can skip c3po, so many of your subquestions do not apply.

看起来您可以跳过 c3po,因此您的许多子问题都不适用。