forked from github/dataease
fix: mongo 支持JDBC连接字符串
This commit is contained in:
parent
b8bfedfe0d
commit
1fce629624
@ -2,6 +2,7 @@ package io.dataease.dto.datasource;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ -9,11 +10,21 @@ public class MongodbConfiguration extends JdbcConfiguration {
|
||||
|
||||
private String driver = "mongodb.jdbc.MongoDriver";
|
||||
private String connectionType;
|
||||
private String extraParams = "rebuildschema=true";
|
||||
|
||||
public String getJdbc() {
|
||||
return "jdbc:mongodb://HOSTNAME:PORT/DATABASE"
|
||||
.replace("HOSTNAME", getHost().trim())
|
||||
.replace("PORT", getPort().toString().trim())
|
||||
.replace("DATABASE", getDataBase().trim());
|
||||
if(StringUtils.isEmpty(extraParams.trim())){
|
||||
return "jdbc:mongodb://HOSTNAME:PORT/DATABASE"
|
||||
.replace("HOSTNAME", getHost().trim())
|
||||
.replace("PORT", getPort().toString().trim())
|
||||
.replace("DATABASE", getDataBase().trim());
|
||||
}else {
|
||||
return "jdbc:mongodb://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
|
||||
.replace("HOSTNAME", getHost().trim())
|
||||
.replace("PORT", getPort().toString().trim())
|
||||
.replace("DATABASE", getDataBase().trim())
|
||||
.replace("EXTRA_PARAMS", getExtraParams().trim());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user