Problems using eclipse Hibernate plugin - could not locate sessionfactory in JNDI

人盡茶涼 提交于 2019-11-29 05:06:40

You can either specify all the connection, password, username etc. directly in a hibernate configuration file, and then load using code like:

Configuration cfg = new Configuration();
cfg.configure();
SessionFactory sf = cfg.buildSessionFactory();

Or, you can obtain it from JNDI. This allows your sysadmin to change the connection, password, username etc. after deployment, by registering a different SessionFactory with JNDI.

You would need to consult your application server's documentation on how to specify JNDI resources with the application server.

Inside of buildsessionfactory method initialize initialcontext.pass the sessionfactory jndi name in the get session factory method( i.e in lookup)

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