如何在Slick 3.1中使用不支持的数据库

By simon at 2018-02-07 • 0人收藏 • 68人看过
<p>在过去,我使用Slick访问服务器中的Vertica数据库。一世 最近把我的Slick版本从2.0升级到3.1。自升级以来,我是 遇到错误(下面的堆栈跟踪)。错误表示光滑 驱动程序无法找到。 一个根据[Slick 3.1文档](http://slick.lightbend.com/doc/3.1.0 /supported-databases.html>),“其他SQL数据库可以是马上加满 具有减少的特征集合“。 我想知道的是 - 是否仍然可以使用“其他”类型 数据库从那些直接支持光滑?如果是这样,怎么样? 我的数据库配置是:
slick.dbs.default.driver="slick.driver.JdbcDriver"
slick.dbs.default.db.driver="com.vertica.jdbc.Driver"
slick.dbs.default.db.url=${some.url}
slick.dbs.default.db.user=${some.user}
slick.dbs.default.db.password=${some.pw}
请注意,感谢[这个堆栈Overflow 响应(https://stackoverflow.com/questions/33000823/cant-connect-to-mysql- 数据库与播放,油滑1-0-1-光滑-3-0-C配置),我也试过了 下面的每一个替换config中的第一行:
slick.dbs.default.driver="slick.driver.JdbcDriver$"
slick.dbs.default.driver="slick.driver.JdbcDriver$class"
slick.dbs.default.driver=slick.driver.JdbcDriver
我也有我的BT文件:
libraryDependencies ++= Seq(
  "com.vertica" % "vertica-jdbc" % "7.0.1",
  "com.typesafe.play" %% "play-slick" % "2.0.0")
请注意,play-slick使用光滑的3.1.0。 全堆栈跟踪:
[ERROR] [10/07/2016 16:43:52.336] [p.a.d.s.DefaultSlickApi] [*] Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of Slick driver "slick.driver.JdbcDriver"
    at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:65)
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.create(SlickApi.scala:89)
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get$lzycompute(SlickApi.scala:81)
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get(SlickApi.scala:80)
    at play.api.db.slick.DefaultSlickApi.dbConfig(SlickApi.scala:66)
    at play.api.db.slick.NamedDatabaseConfigProvider$$anon$1.get(SlickModule.scala:59)
    at utils.liger.DimensionMapper.<init>(DimensionMapper.scala:32)
    at utils.liger.DimensionMapper$$FastClassByGuice$$1320fe73.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.inject.Guice.createInjector(Guice.java:84)
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
    at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47)
    at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
    at play.core.server.ProdServerStart.main(ProdServerStart.scala)
Caused by: java.lang.InstantiationException: slick.driver.JdbcDriver
    at java.lang.Class.newInstance(Class.java:427)
    at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:63)
    ... 36 common frames omitted
Caused by: java.lang.NoSuchMethodException: slick.driver.JdbcDriver.<init>()
    at java.lang.Class.getConstructor0(Class.java:3082)
    at java.lang.Class.newInstance(Class.java:412)
    ... 37 common frames omitted
如果我改用:
slick.dbs.default.driver="slick.driver.JdbcDriver$"
然后:
[ERROR] [10/07/2016 16:36:07.701] [p.a.d.s.DefaultSlickApi] [*] Failed to create Slick database config for key default.
slick.SlickException: Error getting instance of Slick driver "slick.driver.JdbcDriver$"
    at slick.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:65)
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.create(SlickApi.scala:89)
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get$lzycompute(SlickApi.scala:81)
    at play.api.db.slick.DefaultSlickApi$DatabaseConfigFactory.get(SlickApi.scala:80)
    at play.api.db.slick.DefaultSlickApi.dbConfig(SlickApi.scala:66)
    at play.api.db.slick.NamedDatabaseConfigProvider$$anon$1.get(SlickModule.scala:59)
    at controllers.liger.AwdAutomation.<init>(AwdAutomation.scala:43)
    at controllers.liger.AwdAutomation$$FastClassByGuice$$64e5b177.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1051)
    at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:405)
    at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
    at play.api.inject.RoutesProvider$$anonfun$2.apply(BuiltinModule.scala:82)
    at scala.Option.fold(Option.scala:158)
    at play.api.inject.RoutesProvider.get$lzycompute(BuiltinModule.scala:82)
    at play.api.inject.RoutesProvider.get(BuiltinModule.scala:78)
    at play.api.inject.RoutesProvider.get(BuiltinModule.scala:77)
    at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:81)
    at com.google.inject.internal.BoundProviderFactory.provision(BoundProviderFactory.java:72)
    at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:61)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:62)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:56)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:104)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1103)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:145)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:205)
    at com.google.inject.internal.InternalInjectorCreator$1.call(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
    at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:199)
    at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:180)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
    at com.google.inject.Guice.createInjector(Guice.java:96)
    at com.google.inject.Guice.createInjector(Guice.java:84)
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
    at play.core.server.ProdServerStart$.start(ProdServerStart.scala:47)
    at play.core.server.ProdServerStart$.main(ProdServerStart.scala:22)
    at play.core.server.ProdServerStart.main(ProdServerStart.scala)
Caused by: java.lang.ClassNotFoundException: slick.driver.JdbcDriver$
    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.backend.DatabaseConfig$.forConfig(DatabaseConfig.scala:62)
    ... 78 common frames omitted

1 个回复 | 最后更新于 2018-02-07
2018-02-07   #1

使用Slick 3.0时,通用的jdbc驱动程序slick.driver.JdbcDriver$已被弃用(与您一样 可以看到 [源(https://github.com/slick/slICK /斑点/ 3.0 /光滑/ SRC /主/阶/光滑/驱动器/ JdbcProfile.scala#L148)) 然后在版本中删除 [3.1](https://github.com/sliCK /光滑/斑点/ 3.1.0 /光滑/ SRC /主/阶/光滑/驱动器/ JdbcProfile.scala#L127) (这解释了你所看到的错误) 到现在为止,如果是漂亮的3.2,其他数据库可以通过自定义来支持 特质的实现 [slick.jdbc.JdbcProfile](HTTPS:// github.com/slick/slick/blob/3.2.0/slick/src/main/scala/slick/jdbc/JdbcProfile.scala)

登录后方可回帖

Loading...