如何连接休眠和DB2 [英] how to connect hibernate and DB2

查看:82
本文介绍了如何连接休眠和DB2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个使用Struts和Hibernate的应用程序。我当前正在使用Derby数据库。
现在我必须转移到DB2数据库上。

I am running an application that used struts and hibernate. I am currently using Derby database. Now i have to shift on DB2 database.

请告诉我



  • 休眠配置文件中必须执行什么配置?

  • 是否必须设置任何类路径
    变量?

  • 我知道DB2
    有两个jar( db2jcc.jar db2jcc_license_cu.jar )。
    我可能还需要其他罐子吗?

  • what Configuration I have to do in hibernate configuration file?
  • Do I have to set any classpath variable?
  • I know there are two jars for DB2 (db2jcc.jar & db2jcc_license_cu.jar). Is there any other jar I may need?

预先感谢。

推荐答案

它应该与 db2jcc.jar

将以下属性添加到您的 hibernate.cfg.xml

Add below properties to your hibernate.cfg.xml

<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>

<property name="hibernate.connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>

<property name="connection.url">jdbc:db2://<host>:<port50000>/<dbname></property>

<property name="connection.username">dbusername</property>

<property name="connection.password">dbpassword</property>

根据您的配置更改最后3个属性

Change last 3 properties according to your configuration

这篇关于如何连接休眠和DB2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆