Skip to content

Commit

Permalink
Added hikariCP library
Browse files Browse the repository at this point in the history
  • Loading branch information
Satendra kumar committed Aug 16, 2015
1 parent bac4788 commit f5a5611
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
"mysql" % "mysql-connector-java" % "5.1.36",
"ch.qos.logback" % "logback-classic" % "1.1.3",
"com.zaxxer" % "HikariCP-java6" % "2.3.9",
"com.typesafe.slick" %% "slick" % "3.0.1",
"org.scalatest" %% "scalatest" % "2.2.5" % "test",
"com.h2database" % "h2" % "1.4.187" % "test"
Expand Down
26 changes: 26 additions & 0 deletions src/main/scala/com/knol/db/Demo.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.knol.db

import com.knol.db.repo._
import scala.util._
import scala.concurrent.ExecutionContext.Implicits.global

object Demo extends App {

val bankId = BankRepository.create(Bank("ICICI bank"))

bankId.onComplete {
case Success(id) =>

BankProductRepository.create(BankProduct("car loan", id))
BankInfoRepository.create(BankInfo("Goverment", 1000, id))
BankRepository.create(Bank("SBI Bank"))
case _ => println("Error ...........")
}

BankInfoRepository.getAllBankWithInfo().foreach(println)

BankProductRepository.getAllBankWithProduct().foreach(println)

Thread.sleep(10 * 1000)

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ private[connection] object MySqlDB {

import slick.driver.MySQLDriver.api._

val connectionPool = Database.forConfig("dbconf")
val connectionPool = Database.forConfig("mysql")

}
3 changes: 3 additions & 0 deletions src/main/scala/com/knol/db/repo/BankInfoRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.knol.db.repo

import com.knol.db.connection.DBComponent
import scala.concurrent.Future
import com.knol.db.connection.MySqlDBComponent

trait BankInfoRepository extends BankInfoTable { this: DBComponent =>

Expand Down Expand Up @@ -57,4 +58,6 @@ private[repo] trait BankInfoTable extends BankTable { this: DBComponent =>

}

object BankInfoRepository extends BankInfoRepository with MySqlDBComponent

case class BankInfo(owner: String, branches: Int, bankId: Int, id: Option[Int] = None)
3 changes: 3 additions & 0 deletions src/main/scala/com/knol/db/repo/BankProductRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.knol.db.repo

import com.knol.db.connection.DBComponent
import scala.concurrent.Future
import com.knol.db.connection.MySqlDBComponent

trait BankProductRepository extends BankProductTable { this: DBComponent =>

Expand Down Expand Up @@ -57,4 +58,6 @@ private[repo] trait BankProductTable extends BankTable { this: DBComponent =>

}

object BankProductRepository extends BankProductRepository with MySqlDBComponent

case class BankProduct(name: String, bankId: Int, id: Option[Int] = None)
2 changes: 1 addition & 1 deletion src/test/scala/com/knol/db/connection/H2DBComponent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait H2DBComponent extends DBComponent {

val randomDB = "jdbc:h2:mem:test" + UUID.randomUUID().toString() + ";"

val h2Url = randomDB + "MODE=MySql;DATABASE_TO_UPPER=false;INIT=runscript from 'src/test/resources/schema.sql'\\;runscript from 'src/test/resources/schemadata.sql'"
val h2Url = randomDB + " MODE=MySql;DATABASE_TO_UPPER=false;INIT=runscript from 'src/test/resources/schema.sql'\\;runscript from 'src/test/resources/schemadata.sql'"

val db: Database = {
logger.info("Creating test connection ..................................")
Expand Down

0 comments on commit f5a5611

Please sign in to comment.