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
基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01