I have written this very simple code
object PersonDAO {
val db = Database.forConfig("h2mem1")
val people = TableQuery[People]
def checkTable() : Boolean = {
val action = MTable.getTables
val future = db.run(action)
val retVal = future map {result =>
result map {x => x}
}
val x = Await.result(retVal, Duration.Inf)
if (x.length > 0) {
true
} else {
false
}
}
}
However this always fails with error message
play.api.UnexpectedException: Unexpected exception[JdbcSQLException: Invalid value 7 for parameter columnIndex [90008-60]]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:166) ~[play_2.10-2.3.4.jar:2.3.4]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:130) ~[play_2.10-2.3.4.jar:2.3.4]
at scala.Option.map(Option.scala:145) ~[scala-library-2.10.5.jar:na]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:130) ~[play_2.10-2.3.4.jar:2.3.4]
at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:128) ~[play_2.10-2.3.4.jar:2.3.4]
Caused by: org.h2.jdbc.JdbcSQLException: Invalid value 7 for parameter columnIndex [90008-60]
at org.h2.message.Message.getSQLException(Message.java:84) ~[h2-1.0.60.jar:1.0.60]
at org.h2.message.Message.getSQLException(Message.java:88) ~[h2-1.0.60.jar:1.0.60]
at org.h2.message.Message.getInvalidValueException(Message.java:117) ~[h2-1.0.60.jar:1.0.60]
at org.h2.jdbc.JdbcResultSet.checkColumnIndex(JdbcResultSet.java:2857) ~[h2-1.0.60.jar:1.0.60]
at org.h2.jdbc.JdbcResultSet.get(JdbcResultSet.java:2880) ~[h2-1.0.60.jar:1.0.60]
[success] Compiled in 22ms
The H2 version is too old.
Change H2 version to 1.3.176 from 1.0.60 in
build.sbt
and the exception will go away - and the test shall pass. :)