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

查看:29
本文介绍了如何连接hibernate和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 有两个 jars(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

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

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