How can I set the current schema for DB2 using Hibernate/JDBC?

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...




    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.