在 spring 项目中使用 hibernate 工具

发布于 2024-11-19 00:59:28 字数 691 浏览 6 评论 0原文

我有一个带有 spring.xml 数据源设置的现有项目。

xml

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

    <property name="url"
                  value="jdbc:oracle:thin:@xxx:1511:xxx"/>
        <property name="driverClassName"
                  value="oracle.jdbc.OracleDriver"/>
        <property name="username" value="xxx"/>
        <property name="password" value="xxx"/>  

    </bean>

在 eclipse 中如下所示,我单击 new -> other-> hibernate ->休眠控制台配置。如何使用 eclipse 内的 hibernate 工具使用上面的 spring.xml 文件设置连接到数据库?或者有没有办法在 eclipse 内的 hibernate 控制台中手动输入这些设置以连接到数据库,以便我可以对数据库表进行逆向工程?

i have existing project with datasource setup with spring.xml .

the xml look like below

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

    <property name="url"
                  value="jdbc:oracle:thin:@xxx:1511:xxx"/>
        <property name="driverClassName"
                  value="oracle.jdbc.OracleDriver"/>
        <property name="username" value="xxx"/>
        <property name="password" value="xxx"/>  

    </bean>

inside eclipse, i click new ->other->hibernate-> hibernate console configuration. how to use hibernate tool inside eclipse to connect to database using setting of spring.xml file like above? or is there way to manually enter those setting in hibernate console inside eclipse to connect to database so that i can do reverse engineering on database table?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

才能让你更想念 2024-11-26 00:59:28

先安装hibernate工具:

可以看用于屏幕截图的 Hibernate 工具设置
这是一个示例文件,您可以使用它,因为只需输入数据库凭据即可

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  <hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.password">username</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@172.21.91.41:1521:DB</property>
    <property name="hibernate.connection.username">passWord</property>
    <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
</session-factory>
 </hibernate-configuration>

使用上述文本创建 hibernate.cfg.xml 文件,并在配置 hibernate 工具时导入它

Install hibernate tools first:

you can look at Hibernate Tools setup for screen shots
here is a sample file which you can use as it as just entering your DB credentials

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  <hibernate-configuration>
<session-factory>
    <property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
    <property name="hibernate.connection.password">username</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@172.21.91.41:1521:DB</property>
    <property name="hibernate.connection.username">passWord</property>
    <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
</session-factory>
 </hibernate-configuration>

create hibernate.cfg.xml file with the above text and import it while configuring hibernate tools

找个人就嫁了吧 2024-11-26 00:59:28

您可以使用属性标签在 hibernate.cfg.xml 中输入这些配置,

请参阅 此处 获取您可以配置的值列表。

you can enter these configurations in hibernate.cfg.xml using the property tags

refer here for a list of values you can configure..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文