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

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

问题描述

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



更新:它一定是驱动程序版本问题。我升级到后来的驱动程序,并且currentSchema工作。

解决方案

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



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



使用:


currentSchema


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


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?

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

解决方案

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

use:

currentSchema

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天全站免登陆