spring boot : how to set db2 encryption password for column value encryption

时光总嘲笑我的痴心妄想 提交于 2021-02-11 14:49:07

问题


I want to set db2 encryption password command when spring boot starts a connection with my db2. Basically some of the columns in my table are encrypted. I tried hibernate mapper @ColumnTransformer(read="decrypt_char(COLUMN_NAME,'password')",write="encrypt(?,'password')").

That does not work. After some look around I found that I have to set the encryption password with the following command when the database connection is established from spring boot application properties file.

     SET ENCRYPTION PASSWORD ='password'(This is DB2 specific)

I dont see any way of setting this in spring boot. I believe there must be a property defined in application.properties which would set this. Currently I am just passing db2 connection as per following

spring.datasource.url=url
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driver-class-name=om.ibm.db2.jcc.DB2Driver

Any help is appreciated.

回答1:


If the question is on how to pass the encryption password special registry variable setting via jdbc url, then the answer is: you need to add to the url something like the following:

...;specialRegisters=ENCRYPTION PASSWORD='password';

URL format for IBM Data Server Driver for JDBC and SQLJ type 4 connectivity



来源:https://stackoverflow.com/questions/53126455/spring-boot-how-to-set-db2-encryption-password-for-column-value-encryption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!