问题描述
如何将Struts 2与hibernate和PostgreSQL连接?
hibernate.connection.driver_class> org.postgresql.Driver< /性>< property name =hibernate.connection.url> jdbc:postgresql:// localhost / jvmhubtutorial< / property>
< property name =hibernate.connection.username>用户< / property>
< property name =hibernate.connection.password>密码< / property>
您可以通过servlet上下文来集成Hibernate和Struts2,可以共享会话工厂。会话工厂用于打开Hibernate会话并使用它来执行对数据库的查询。这里有一个这样集成的。
$ b $在Struts2中有非官方的插件叫做Struts2 Full Hibernate Plugin或者 struts2-s2hibernate ,它提供了与Hibernate的集成。有例子:
How to connect Struts 2 with hibernate and PostgreSQL?
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/jvmhubtutorial</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">password</property>
You can integrate Hibernate and Struts2 via servlet context where you can share the session factory. The session factory is used to open Hibernate session and use it to perform queries to the database. Here an example of such integration.
In Struts2 there's unofficial plugin called Struts2 Full Hibernate Plugin or struts2-s2hibernate that provides an integration with Hibernate. There're examples:
- Struts2 hibernate integration via s2hibernate plugin
- Struts 2 + Hibernate integration with "Full Hibernate Plugin"
这篇关于如何将Struts 2与Hibernate和PostgreSQL连接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!