How to set up hibernate to use Glassfish connection pool?

巧了我就是萌 提交于 2020-01-13 19:34:07

问题


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.

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:

hibernate.connection.datasource
hibernate.jndi.url 
hibernate.jndi.class 
hibernate.connection.username
hibernate.connection.password
  • Would datasource be the same as the hibernate.connection.datasource set 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?

回答1:


This article about hibernate basics seems 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...

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



来源:https://stackoverflow.com/questions/2508466/how-to-set-up-hibernate-to-use-glassfish-connection-pool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!