代码优化
This commit is contained in:
@@ -4,7 +4,6 @@ import com.yanghuanglin.seq.enums.DbType;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
@@ -134,9 +133,8 @@ public class GeneratorConfig {
|
||||
|
||||
public DbType getDbType() {
|
||||
if (this.dbType == null) {
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = dataSource.getConnection();
|
||||
Connection connection = dataSource.getConnection();
|
||||
String productName = connection.getMetaData().getDatabaseProductName();
|
||||
this.dbType = DbType.of(productName);
|
||||
} catch (SQLException e) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public enum DbType {
|
||||
*/
|
||||
public static DbType of(String productName) {
|
||||
for (DbType value : DbType.values()) {
|
||||
if (value.name().equalsIgnoreCase(productName.replace(" ","_"))) {
|
||||
if (value.name().equalsIgnoreCase(productName.replace(" ", "_"))) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user