Slick MTable.getTables 总是因意外异常而失败 [JdbcSQLException:参数 columnIndex [90008-60] 的无效值 7]
Slick MTable.getTables always fails with Unexpected exception[JdbcSQLException: Invalid value 7 for parameter columnIndex [90008-60]]
我写了这个非常简单的代码
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
}
}
}
然而,这总是失败并显示错误消息
play.api.UnexpectedException: Unexpected exception[JdbcSQLException: Invalid value 7 for parameter columnIndex [90008-60]]
at play.core.ReloadableApplication$$anonfun$get$$anonfun$apply$$anonfun.apply(ApplicationProvider.scala:166) ~[play_2.10-2.3.4.jar:2.3.4]
at play.core.ReloadableApplication$$anonfun$get$$anonfun$apply$$anonfun.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$$anonfun$apply.apply(ApplicationProvider.scala:130) ~[play_2.10-2.3.4.jar:2.3.4]
at play.core.ReloadableApplication$$anonfun$get$$anonfun$apply.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
H2版本太旧
在 build.sbt
中将 H2 版本从 1.0.60 更改为 1.3.176,异常将消失 - 测试将通过。 :)
我写了这个非常简单的代码
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
}
}
}
然而,这总是失败并显示错误消息
play.api.UnexpectedException: Unexpected exception[JdbcSQLException: Invalid value 7 for parameter columnIndex [90008-60]]
at play.core.ReloadableApplication$$anonfun$get$$anonfun$apply$$anonfun.apply(ApplicationProvider.scala:166) ~[play_2.10-2.3.4.jar:2.3.4]
at play.core.ReloadableApplication$$anonfun$get$$anonfun$apply$$anonfun.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$$anonfun$apply.apply(ApplicationProvider.scala:130) ~[play_2.10-2.3.4.jar:2.3.4]
at play.core.ReloadableApplication$$anonfun$get$$anonfun$apply.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
H2版本太旧
在 build.sbt
中将 H2 版本从 1.0.60 更改为 1.3.176,异常将消失 - 测试将通过。 :)