forked from github/dataease
Merge branch 'dev' of github.com:dataease/dataease into dev
This commit is contained in:
commit
07ad5201b1
@ -5,20 +5,30 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class MysqlConfiguration extends JdbcConfiguration {
|
public class MysqlConfiguration extends JdbcConfiguration {
|
||||||
|
|
||||||
private String driver = "com.mysql.jdbc.Driver";
|
private String driver = "com.mysql.jdbc.Driver";
|
||||||
private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
|
private String extraParams = "characterEncoding=UTF-8&connectTimeout=5000&useSSL=false&allowPublicKeyRetrieval=true&zeroDateTimeBehavior=convertToNull";
|
||||||
|
private List<String> illegalParameters = Arrays.asList("autoDeserialize", "queryInterceptors", "statementInterceptors", "detectCustomCollations");
|
||||||
|
|
||||||
public String getJdbc() {
|
public String getJdbc() {
|
||||||
if(StringUtils.isEmpty(extraParams.trim())){
|
if (StringUtils.isEmpty(extraParams.trim())) {
|
||||||
return "jdbc:mysql://HOSTNAME:PORT/DATABASE"
|
return "jdbc:mysql://HOSTNAME:PORT/DATABASE"
|
||||||
.replace("HOSTNAME", getHost().trim())
|
.replace("HOSTNAME", getHost().trim())
|
||||||
.replace("PORT", getPort().toString().trim())
|
.replace("PORT", getPort().toString().trim())
|
||||||
.replace("DATABASE", getDataBase().trim());
|
.replace("DATABASE", getDataBase().trim());
|
||||||
}else {
|
} else {
|
||||||
|
for (String illegalParameter : illegalParameters) {
|
||||||
|
if (getExtraParams().contains(illegalParameter)) {
|
||||||
|
throw new RuntimeException("Illegal parameter: " + illegalParameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
|
return "jdbc:mysql://HOSTNAME:PORT/DATABASE?EXTRA_PARAMS"
|
||||||
.replace("HOSTNAME", getHost().trim())
|
.replace("HOSTNAME", getHost().trim())
|
||||||
.replace("PORT", getPort().toString().trim())
|
.replace("PORT", getPort().toString().trim())
|
||||||
|
Loading…
Reference in New Issue
Block a user