it.agilelab.darwin.connector.postgres.PostgresConnection.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of darwin-postgres-connector_2.10 Show documentation
Show all versions of darwin-postgres-connector_2.10 Show documentation
Avro Schema Evolution made easy
The newest version!
package it.agilelab.darwin.connector.postgres
import java.sql.{ Connection, DriverManager }
import com.typesafe.config.Config
trait PostgresConnection {
private var connectionUrl: String = ""
private val driverName: String = "org.postgresql.Driver"
protected def setConnectionConfig(config: Config) = {
val db = config.getString(ConfigurationKeys.DATABASE)
val host = config.getString(ConfigurationKeys.HOST)
val user = config.getString(ConfigurationKeys.USER)
val password = config.getString(ConfigurationKeys.PASSWORD)
connectionUrl = s"jdbc:postgresql://$host/$db?user=$user&password=$password"
}
protected def getConnection: Connection = {
Class.forName(driverName)
val connection: Connection = DriverManager.getConnection(connectionUrl)
connection
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy