Skip to content

Commit 6b32873

Browse files
authored
fix: properties not work when use custom driver (#150)
* fix: properties not work when use custom driver * fix: checkstyle
1 parent 3450947 commit 6b32873

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

core/src/main/java/com/databasir/core/infrastructure/connection/CustomDatabaseConnectionFactory.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,17 @@ public Connection getConnection(Context context) throws SQLException {
7171
throw DomainErrors.CONNECT_DATABASE_FAILED.exception("驱动初始化异常:" + e.getMessage());
7272
}
7373

74+
Properties info = new Properties();
75+
info.put("user", context.getUsername());
76+
info.put("password", context.getPassword());
77+
if (context.getProperties() != null && !context.getProperties().isEmpty()) {
78+
info.putAll(context.getProperties());
79+
}
7480
String urlPattern = type.getUrlPattern();
7581
String jdbcUrl = urlPattern.replace("{{jdbc.protocol}}", type.getJdbcProtocol())
7682
.replace("{{db.url}}", context.getUrl())
7783
.replace("{{db.name}}", context.getDatabaseName())
7884
.replace("{{db.schema}}", context.getSchemaName());
79-
Properties info = new Properties();
80-
info.put("user", context.getUsername());
81-
info.put("password", context.getPassword());
8285
return driver.connect(jdbcUrl, info);
8386
}
8487

0 commit comments

Comments
 (0)