how to connect hibernate and DB2(如何连接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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何连接hibernate和DB2
基础教程推荐
- 不推荐使用 Api 注释的描述 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 多个组件的复杂布局 2022-01-01
