2
votes

I'm starting to learn and experiment with slick.

I'm trying to connect to an oracle dev database, set up by our DBA.

However i am encountering issue and i can't connect.

Here is what i did so far:

  oracledev = {
   url = "jdbc:oracle:thin:@//vdevdbms2:4208/TPSDEV.IADB.ORG"
   driver = com.typesafe.slick.driver.oracle.OracleDriver
   connectionPool = disable
   keepAliveConnection = true
  }

I have the following in my build

resolvers += "Typesafe Releases" at "http://repo.typesafe.com/typesafe/maven-releases/"

libraryDependencies ++=
  Seq(
        "com.smartlogic.osclient" % "Semaphore-OS-Client" % "Semaphore-3.7.2",
        "com.typesafe.slick" %% "slick-extensions" % "3.1.0",
        "org.slf4j" % "slf4j-nop" % "1.6.4"
     )

The code so far is simply:

object SlickSpike extends App {

  val db = Database.forConfig("oracledev")

}

I get the following error:

Exception in thread "main" java.lang.ClassNotFoundException: disable at java.lang.ClassLoader.findClass(ClassLoader.java:530) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at slick.util.ClassLoaderUtil$$anon$1.loadClass(ClassLoaderUtil.scala:12) at slick.jdbc.JdbcDataSource$.loadFactory$1(JdbcDataSource.scala:30) at slick.jdbc.JdbcDataSource$.forConfig(JdbcDataSource.scala:39) at slick.jdbc.JdbcBackend$DatabaseFactoryDef$class.forConfig(JdbcBackend.scala:268) at slick.jdbc.JdbcBackend$$anon$3.forConfig(JdbcBackend.scala:33) at SlickSpike$.delayedEndpoint$SlickSpike$1(SlickSpike.scala:16) at SlickSpike$delayedInit$body.apply(SlickSpike.scala:14) at scala.Function0$class.apply$mcV$sp(Function0.scala:34) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) at scala.App$$anonfun$main$1.apply(App.scala:76) at scala.App$$anonfun$main$1.apply(App.scala:76) at scala.collection.immutable.List.foreach(List.scala:381) at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35) at scala.App$class.main(App.scala:76) at SlickSpike$.main(SlickSpike.scala:14) at SlickSpike.main(SlickSpike.scala) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

If i remove the line: **

connectionPool = disable

**

Then i get the following error:

Exception in thread "main" java.lang.ClassNotFoundException: slick.jdbc.hikaricp.HikariCPJdbcDataSource$ at java.lang.ClassLoader.findClass(ClassLoader.java:530) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at slick.util.ClassLoaderUtil$$anon$1.loadClass(ClassLoaderUtil.scala:12) at slick.jdbc.JdbcDataSource$.loadFactory$1(JdbcDataSource.scala:30) at slick.jdbc.JdbcDataSource$.forConfig(JdbcDataSource.scala:35) at slick.jdbc.JdbcBackend$DatabaseFactoryDef$class.forConfig(JdbcBackend.scala:268) at slick.jdbc.JdbcBackend$$anon$3.forConfig(JdbcBackend.scala:33) at SlickSpike$.delayedEndpoint$SlickSpike$1(SlickSpike.scala:16) at SlickSpike$delayedInit$body.apply(SlickSpike.scala:14) at scala.Function0$class.apply$mcV$sp(Function0.scala:34) at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) at scala.App$$anonfun$main$1.apply(App.scala:76) at scala.App$$anonfun$main$1.apply(App.scala:76) at scala.collection.immutable.List.foreach(List.scala:381) at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:35) at scala.App$class.main(App.scala:76) at SlickSpike$.main(SlickSpike.scala:14) at SlickSpike.main(SlickSpike.scala)

What am I doing wrong ?

I would simply like, to have a connection pool of 10, and connect to the database but i have no idea of how to set it up. Can someone help ?

Edit2

I solve the initial issue but i still have question and can't get everything to work.

I change my build as such:

libraryDependencies ++=
  Seq(
       "org.slf4j" % "slf4j-api" % "1.7.13",
       "org.slf4j" % "slf4j-simple" % "1.7.13",
       "com.smartlogic.osclient" % "Semaphore-OS-Client" % "Semaphore-3.7.2"  exclude("org.slf4j","slf4j-log4j12"),
       "com.typesafe.slick" %% "slick" % "3.1.0",
       "com.typesafe.slick" %% "slick-extensions" % "3.1.0",
       "com.typesafe.slick" %% "slick-hikaricp" % "3.1.0",
       "com.oracle" % "ojdbc6" % "11.2.0.2.0"
     )

I resorted to add slick-hikaricp, even if I did not intent to use originally. Also I understood now that the oracle driver in the config, was the actual oracle drive, not the slick one. This is actually reflected in the change i did to my config as can be seen below:

oracledev = {
  url = "jdbc:oracle:thin:@//vdevdbms2:4208/TPSDEV.IADB.ORG"
  driver = oracle.jdbc.OracleDriver
  //  connectionPool = disable
  keepAliveConnection = true
  //databaseName = "BRIKPOOLPARTYDEV"
  user = "*******"
  password = "*******"
}

Questions:

1 - Is slick-hikaricp required by default when using Oracle. Indeed if i do not add it and comment out connectionPool = disable, which in my case, do not work when uncommented anyway, the program does not compile.

2 - I'm still not able to connect, am i missing something ?

Please help

3

3 Answers

1
votes

the oracle, db2, and ms sql drivers are not free. there is a separate 'slick-extensions' package that contains drivers for them that you can use for development. but you have to fork over cold cash for production use of them.

1
votes

You should download and put the ojdbc7.jar in a folder in your root project (lib) and have it rebuilt.

0
votes

The entry in the config for connectionPool should be disabled instead of disable.

This config entry is used when deciding what JdbcDataSource will be loaded. The disable config entry tries to load a JdbcDataSourceFactoryfactory with the name disable.