io.quarkiverse.mybatis.runtime.QuarkusDatabaseIdProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-mybatis Show documentation
Show all versions of quarkus-mybatis Show documentation
MyBatis SQL mapper framework for Java
The newest version!
package io.quarkiverse.mybatis.runtime;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.ibatis.mapping.DatabaseIdProvider;
import org.eclipse.microprofile.config.ConfigProvider;
public class QuarkusDatabaseIdProvider implements DatabaseIdProvider {
@Override
public String getDatabaseId(final DataSource dataSource) throws SQLException {
if (dataSource instanceof QuarkusDataSource ds) {
String name = ds.getDataSourceName();
return ConfigProvider.getConfig().getOptionalValue(
"quarkus.mybatis." + ("".equals(name) ? "" : name + ".") + "database-id", String.class)
.orElse(null);
}
return null;
}
}