如何使用 Hibernate/JDBC 为 DB2 设置当前模式? [英] How can I set the current schema for DB2 using Hibernate/JDBC?

查看:12
本文介绍了如何使用 Hibernate/JDBC 为 DB2 设置当前模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用 currentSchema=MYSCHEMA;在我的 JDBC URL 连接中,但我们使用的 DB2 版本不再支持,显示错误目标服务器上不允许使用currentSchema"属性".我试过使用 hibernate.default_schema,但它不会自动将模式添加到我的表名中.我不想在每个 @Table 注释上设置架构,因为我需要在测试和生产之间更改它.还有其他方法可以设置连接还是通过 Hibernate?

I used to use currentSchema=MYSCHEMA; in my JDBC URL connection, but the version of DB2 we're using no longer supports that, showing the error 'The "currentSchema" property is not allowed on the target server'. I've tried using hibernate.default_schema, but it's not automatically adding the schema to my table names. I don't want to set the schema on every @Table annotation since I'll need to change it between test and production. Is there another way to set on the connection or via Hibernate?

更新:一定是驱动版本问题.我升级到更高版本的驱动程序并且 currentSchema 工作.

Update: it must have been a driver version issue. I upgraded to later drivers and currentSchema worked.

推荐答案

9.7 (Latest) db的所有属性都在这里...

All the properties for the 9.7 (Latest) db are here...

https://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=/com.ibm.db2.luw.apdv.java.doc/doc/r0052607.html

使用:

当前架构

指定用于在动态准备的 SQL 语句中限定非限定数据库对象的默认模式名称.此属性的值设置数据库服务器上 CURRENT SCHEMA 专用寄存器中的值.架构名称区分大小写,并且必须以大写字符指定.

Specifies the default schema name that is used to qualify unqualified database objects in dynamically prepared SQL statements. The value of this property sets the value in the CURRENT SCHEMA special register on the database server. The schema name is case-sensitive, and must be specified in uppercase characters.

这篇关于如何使用 Hibernate/JDBC 为 DB2 设置当前模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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