mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 02:32:33 +08:00
Part of the English translation work, and some typos in the original project were corrected.
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<!--properties的配置文件会和编译后的class文件放在一起-->
|
||||
<!--The properties configuration file will be placed together with the compiled class file-->
|
||||
<include>**/*.json</include>
|
||||
</includes>
|
||||
</resource>
|
||||
|
@ -36,20 +36,20 @@ public class PostgreSQLDBManage extends DefaultDBManage implements DBManage {
|
||||
|
||||
|
||||
public String replaceDatabaseInJdbcUrl(String url, String newDatabase) {
|
||||
// 先在"?"字符处分割字符串,处理查询参数
|
||||
// First split the string at the "?" character and process the query parameters
|
||||
String[] urlAndParams = url.split("\\?");
|
||||
String urlWithoutParams = urlAndParams[0];
|
||||
|
||||
// 在URL中的"/"字符处分割字符串
|
||||
// Split string at "/" character in URL
|
||||
String[] parts = urlWithoutParams.split("/");
|
||||
|
||||
// 取最后一部分,即数据库名,并替换为新的数据库名
|
||||
// Take the last part, the database name, and replace it with the new database name
|
||||
parts[parts.length - 1] = newDatabase;
|
||||
|
||||
// 将修改后的部分重新组合成URL
|
||||
// Reassemble the modified parts into a URL
|
||||
String newUrlWithoutParams = String.join("/", parts);
|
||||
|
||||
// 如果存在查询参数,重新添加
|
||||
// If query parameters exist, add them again
|
||||
String newUrl = urlAndParams.length > 1 ? newUrlWithoutParams + "?" + urlAndParams[1] : newUrlWithoutParams;
|
||||
|
||||
return newUrl;
|
||||
|
Reference in New Issue
Block a user