Dameng JAVA program specifies the access mode (the mode name contains special characters)

1> Question:

Recently, I encountered a problem in the migration of the project. The Dameng database used by the SpringBoot project, we have established a corresponding account for each subsystem under the platform, so that when the program in the subsystem uses this account to log in, the default is Read the table under your own schema (schema), and you don't need to use 模式名.对象名the way to access it in SQL. Recently, when it comes to database migration, we use a large account on the platform, and all subsystems access data in their own mode through this account. However, by default, the login account reads the default mode of the current account, so without modifying the sql, we must specify the access mode of each subsystem. Such modification is definitely impractical.

2> The official solution:

Dameng technical documentation: https://eco.dameng.com/docs/zh-cn/faq/faq-java.html

When I checked the Dameng technical documentation, I found that there was such an official explanation:

insert image description here

3> Problems found in actual use:

However, our user name contains some special symbols, like XXX-this, with a unified prefix. When such a url connection string is constructed, jdbc:dm://192.168.15.35:5236?schema=XXX-XXXa connection exception or unrecognized symbol is always reported when the program starts [-]:
insert image description here

So I changed a test library, similar to TEST2the one above, and the program started successfully. It seems that it is because of the special characters. First, I tried to use the escape character , but I still didn’t recognize it; then since it was not recognized by Dameng, I wrapped it in double quotes %2Dwith the escape character of Dameng , and the result ""I still started to report an error; I tried many times and consulted a lot of information but couldn't find a solution. I accidentally thought that it was because the double quotes were ignored, so I added another layer to try, that's it, the result was successful jdbc:dm://192.168.15.35:5236?schema=""XXX-XXX"". The correct table is also accessed. I don't know the reason for this writing for the time being, and I will study it in depth later.

Summarize

① If you want to access tables in other modes (non-default mode) after logging in, you can use schema=模式名it in the jdbc connection string.

② If the mode name contains special characters, you need to wrap the mode name with two layers of double quotation marks, that is: schema=""模式名""this way.

Guess you like

Origin blog.csdn.net/backbug/article/details/125387210