'For SqlServer please explicitly choose either sqlserver16 or sqlserver17 as the platform via DatabaseConfig.setDatabasePlatformName
I am working on Java Play Framework template 2.8.13 with sbt 1.6.2 and Scala 2.13.8 and I come from an upgrade play from 2.1.5 to the mentioned. The problem is when I try to connect to SQL Server (SQL Server Management Studio v18.4 with server version 14.0.1000.169)
My application.conf:
play.db {
config = "db"
default = "default"
prototype {
# Sets a fixed JDBC connection pool size of 50
hikaricp.minimumIdle = 5
hikaricp.maximumPoolSize = 5
}
}
db {
default.hikaricp.connectionTestQuery="SELECT 1"
default.driver=net.sourceforge.jtds.jdbc.Driver
default.url="jdbc:jtds:sqlserver://127.0.0.1:1433/dbName"
default.username="sa"
default.password="test12"
default.databasePlatformName="sqlserver17"
default.logstatements=true
}
ebean.default = ["models.*"]
My plugin.sbt
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.15")
addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8-scaffold" % "0.13.1")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
addSbtPlugin("com.typesafe.play" %% "sbt-play-ebean" % "6.2.0-RC4")
My build.sbt
name := """PRECIEMSA"""
organization := "com.ciemsa"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)
scalaVersion := "2.13.8"
libraryDependencies += guice
libraryDependencies += ehcache
libraryDependencies += javaJdbc
libraryDependencies += jdbc
libraryDependencies += "com.google.inject" % "guice" % "5.1.0"
libraryDependencies += "com.typesafe.play" %% "play-ebean" % "6.2.0-RC4"
libraryDependencies += "net.sourceforge.jtds" % "jtds" % "1.3.1"
My Global.java
@Singleton
public class Global{
@Inject
public Global(Database pDb) {
this.db = pDb;
}
}
I already tried
- Verify the connection to SQL > OK
- new driver like:
db.default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.default.url="jdbc:sqlserver://localhost\\MSSQLSERVER:1433;databaseName=dbName"
db.default.username=sa
db.default.password="test12"
db.default.logSql=true
db.default.hikaricp.connectionTestQuery="SELECT 1"
and variants. This last is running on one older version of project with play 2.1.5
No idea how can connect now.
So, maybe someone have an example application.conf for SQL Server?
Stack trace error.
2022-05-23 13:55:52 [1;31mERROR[0;39m [36mp.api.http.DefaultHttpErrorHandler[0;39m [35m[0;39m
! @7nm0g1542 - Internal server error, for (GET) [/] ->
play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:
1) Error injecting constructor, javax.persistence.PersistenceException: java.lang.IllegalArgumentException: For SqlServer please explicitly choose either sqlserver16 or sqlserver17 as the platform via DatabaseConfig.setDatabasePlatformName. Refer to issue #1340 for more details
at play.db.ebean.EbeanDynamicEvolutions.<init>(EbeanDynamicEvolutions.java:36)
at play.db.ebean.EbeanDynamicEvolutions.class(EbeanDynamicEvolutions.java:33)
while locating play.db.ebean.EbeanDynamicEvolutions
at play.db.ebean.EbeanModule.bindings(EbeanModule.java:21):
Binding(class play.api.db.evolutions.DynamicEvolutions to ConstructionTarget(class play.db.ebean.EbeanDynamicEvolutions) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$4)
while locating play.api.db.evolutions.DynamicEvolutions
Caused by: javax.persistence.PersistenceException: java.lang.IllegalArgumentException: For SqlServer please explicitly choose either sqlserver16 or sqlserver17 as the platform via DatabaseConfig.setDatabasePlatformName. Refer to issue #1340 for more details
at io.ebeaninternal.server.core.DatabasePlatformFactory.create(DatabasePlatformFactory.java:70)
at io.ebeaninternal.server.core.DefaultContainer.setDatabasePlatform(DefaultContainer.java:215)
at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:99)
at io.ebeaninternal.server.core.DefaultContainer.createServer(DefaultContainer.java:35)
at io.ebean.DatabaseFactory.createInternal(DatabaseFactory.java:130)
at io.ebean.DatabaseFactory.create(DatabaseFactory.java:78)
at io.ebean.EbeanServerFactory.create(EbeanServerFactory.java:50)
at play.db.ebean.EbeanDynamicEvolutions.lambda$start$2(EbeanDynamicEvolutions.java:50)
at java.util.HashMap.forEach(HashMap.java:1289)
at play.db.ebean.EbeanDynamicEvolutions.start(EbeanDynamicEvolutions.java:50)
at play.db.ebean.EbeanDynamicEvolutions.<init>(EbeanDynamicEvolutions.java:39)
at play.db.ebean.EbeanDynamicEvolutions$$FastClassByGuice$$52c94231.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:213)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:111)
at com.google.inject.Guice.createInjector(Guice.java:87)
at com.google.inject.Guice.createInjector(Guice.java:78)
at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:200)
at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:155)
at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
at play.core.server.DevServerStart$$anon$1.$anonfun$reload$2(DevServerStart.scala:193)
at play.utils.Threads$.withContextClassLoader(Threads.scala:22)
at play.core.server.DevServerStart$$anon$1.reload(DevServerStart.scala:185)
at play.core.server.DevServerStart$$anon$1.get(DevServerStart.scala:148)
at play.core.server.AkkaHttpServer.handleRequest(AkkaHttpServer.scala:302)
at play.core.server.AkkaHttpServer.$anonfun$createServerBinding$1(AkkaHttpServer.scala:224)
at akka.stream.impl.fusing.MapAsync$$anon$30.onPush(Ops.scala:1307)
at akka.stream.impl.fusing.GraphInterpreter.processPush(GraphInterpreter.scala:542)
at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:496)
at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:390)
at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:650)
at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:521)
at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:625)
at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:800)
at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:818)
at akka.actor.Actor.aroundReceive(Actor.scala:537)
at akka.actor.Actor.aroundReceive$(Actor.scala:535)
at akka.stream.impl.fusing.ActorGraphInterpreter.aroundReceive(ActorGraphInterpreter.scala:716)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:580)
at akka.actor.ActorCell.invoke(ActorCell.scala:548)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
at akka.dispatch.Mailbox.run(Mailbox.scala:231)
at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)
Caused by: java.lang.IllegalArgumentException: For SqlServer please explicitly choose either sqlserver16 or sqlserver17 as the platform via DatabaseConfig.setDatabasePlatformName. Refer to issue #1340 for more details
at io.ebeaninternal.server.core.DatabasePlatformFactory.byDatabaseMeta(DatabasePlatformFactory.java:153)
at io.ebeaninternal.server.core.DatabasePlatformFactory.byDataSource(DatabasePlatformFactory.java:135)
at io.ebeaninternal.server.core.DatabasePlatformFactory.create(DatabasePlatformFactory.java:67)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
