datamaintain.db.driver.jdbc.JdbcDriverConfig.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of datamaintain-driver-jdbc Show documentation
Show all versions of datamaintain-driver-jdbc Show documentation
One tool to maintain all your database schemas!
package datamaintain.db.driver.jdbc
import datamaintain.core.config.ConfigKey
import datamaintain.core.config.getProperty
import datamaintain.core.db.driver.DBType
import datamaintain.core.db.driver.DatamaintainDriverConfig
import datamaintain.core.db.driver.DriverConfigKey
import mu.KotlinLogging
import java.util.*
private val logger = KotlinLogging.logger {}
data class JdbcDriverConfig @JvmOverloads constructor(
override val uri: String,
override val trustUri: Boolean,
override val printOutput: Boolean = DriverConfigKey.DB_PRINT_OUTPUT.default!!.toBoolean(),
override val saveOutput: Boolean = DriverConfigKey.DB_SAVE_OUTPUT.default!!.toBoolean()
) : DatamaintainDriverConfig(DBType.JDBC.string, uri, trustUri, printOutput, saveOutput, JdbcConnectionStringBuilder()) {
companion object {
@JvmStatic
fun buildConfig(props: Properties): JdbcDriverConfig {
ConfigKey.overrideBySystemProperties(props, DriverConfigKey.values().asList())
return JdbcDriverConfig(
props.getProperty(DriverConfigKey.DB_URI),
props.getProperty(DriverConfigKey.DB_TRUST_URI).toBoolean(),
props.getProperty(DriverConfigKey.DB_SAVE_OUTPUT).toBoolean(),
props.getProperty(DriverConfigKey.DB_TRUST_URI).toBoolean()
)
}
}
override fun toDriver(connectionString: String) = JdbcDriver(connectionString)
override fun log() {
logger.info { "JDBC driver configuration: " }
logger.info { "- jdbc uri -> $uri" }
logger.info { "- trust uri -> $trustUri" }
logger.info { "- print output -> $printOutput" }
logger.info { "- save output -> $saveOutput" }
logger.info { "" }
}
}