@@ -145,6 +145,9 @@ public enum DatabaseType {
|
||||
* @throws IllegalArgumentException if none is found.
|
||||
*/
|
||||
public static DatabaseType fromProductName(String productName) {
|
||||
if (productName.equals("MariaDB")) {
|
||||
productName = "MySQL";
|
||||
}
|
||||
if (!dbNameMap.containsKey(productName)) {
|
||||
throw new IllegalArgumentException(
|
||||
"DatabaseType not found for product name: [" + productName + "]");
|
||||
|
||||
@@ -101,8 +101,7 @@ public class TaskExecutionDaoFactoryBean implements FactoryBean<TaskExecutionDao
|
||||
this.dao = new JdbcTaskExecutionDao(dataSource, this.tablePrefix);
|
||||
String databaseType;
|
||||
try {
|
||||
databaseType = org.springframework.batch.support.DatabaseType
|
||||
.fromMetaData(dataSource).name();
|
||||
databaseType = DatabaseType.fromMetaData(dataSource).name();
|
||||
}
|
||||
catch (MetaDataAccessException e) {
|
||||
throw new IllegalStateException(e);
|
||||
|
||||
@@ -45,6 +45,7 @@ public class DatabaseTypeTests {
|
||||
assertThat(fromProductName("Oracle")).isEqualTo(ORACLE);
|
||||
assertThat(fromProductName("PostgreSQL")).isEqualTo(POSTGRES);
|
||||
assertThat(fromProductName("MySQL")).isEqualTo(MYSQL);
|
||||
assertThat(fromProductName("MariaDB")).isEqualTo(MYSQL);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@@ -76,4 +77,10 @@ public class DatabaseTypeTests {
|
||||
assertThat(DatabaseType.fromMetaData(ds)).isEqualTo(MYSQL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFromMetaDataForMariaDB() throws Exception {
|
||||
DataSource ds = TestDBUtils.getMockDataSource("MariaDB");
|
||||
assertThat(DatabaseType.fromMetaData(ds)).isEqualTo(MYSQL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user