2010-03-24 164 views
2

我在Glassfish中建立了一个连接池,并为其安装了一个jndi资源。我难以理解如何配置hibernate来获取它。如何设置休眠以使用Glassfish连接池?

我遇到了很多写作配置它使用C3P0连接池。那么我迷路了。我发现我需要设置:

hibernate.connection.datasource 
hibernate.jndi.url 
hibernate.jndi.class 
hibernate.connection.username 
hibernate.connection.password 
  • 将数据源是相同的连接池hibernate.connection.datasource集?
  • hibernate.jndi.class会是什么?
  • 连接数据库或应用程序服务器的hibernate.connection.username和hibernate.connection.password?我认为这是数据库,但为什么我需要它们,因为这些都是在appserver中设置的?
+0

你见过? http://docs.jboss.org/hibernate/stable/core/reference/en/html/session-configuration.html#configuration-optional-jndi – Jeremy 2010-03-24 14:33:34

+0

我其实已经去过那个页面,但没有那个部分。也许这只是一大早,但对我来说仍然有点神秘。感谢您的链接。 – 2010-03-24 14:48:24

+0

@Jer这似乎是将SessionFactory作为JNDI资源来使用。这是一回事吗?基本上我只关心让Hibernate使用Glassfish连接池。 – 2010-03-24 16:15:30

回答

3

这个article about hibernate basics似乎有你想要的信息。搜索字符串'使用JNDI数据源'。清单2很重要。您可能想要将其与清单1进行比较...

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

+0

谢谢你做到了。 – 2010-03-24 19:19:51