You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
929 B
36 lines
929 B
5 years ago
|
package config;
|
||
|
|
||
|
import org.hibernate.dialect.Dialect;
|
||
|
import org.hibernate.dialect.MySQL57Dialect;
|
||
|
|
||
|
import java.sql.Driver;
|
||
|
|
||
|
public enum DBType{
|
||
|
mysql57(com.mysql.cj.jdbc.Driver.class, MySQL57Dialect.class);
|
||
|
|
||
|
private Class<? extends Driver> driver;
|
||
|
private Class<? extends Dialect> dialect;
|
||
|
|
||
|
DBType(Class<? extends Driver> driver, Class<? extends Dialect> dialect) {
|
||
|
this.driver = driver;
|
||
|
this.dialect = dialect;
|
||
|
}
|
||
|
|
||
|
public Class<? extends Driver> getDriver() {
|
||
|
return driver;
|
||
|
}
|
||
|
|
||
|
public Class<? extends Dialect> getDialect() {
|
||
|
return dialect;
|
||
|
}
|
||
|
|
||
|
public String getUrl(String host,int port,String name){
|
||
|
switch (DBType.valueOf(this.name())){
|
||
|
case mysql57: return "jdbc:mysql://" + host + ":" + port + "/" + name + "?serverTimezone=GMT%2b8";
|
||
|
default:throw new RuntimeException("NotFound type:"+this.name());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|