javaのプログラムを下記環境で構築しようとしていますが、
DBへの接続ができず困っています。
どなたかこの問題にご回答いただければ、幸いです。
play framework2.4
###前提・実現したいこと
javaでプログラムを作成
1.使用言語
java1.8
2.使用フレームワーク
play framework2.4
3.DB
SQLServer2005
4.IDE
Eclipse all in one
Version: Mars.2 Release (4.5.2)
###発生している問題・エラーメッセージ
play2.4から上記DBに接続しようとするとエラーになる。
エラーメッセージ
C:\pleiades\workspace\NewJyucyu_Play2.4.6>activator -jvm-debug 9999 run
ACTIVATOR_HOME=C:\pleiades\playframework\activator-1.3.9-minimal
Listening for transport dt_socket at address: 9999
[info] Loading project definition from C:\pleiades\workspace\NewJyucyu_Play2.4.6\project
[info] Set current project to NewJyucyu (in build file:/C:/pleiades/workspace/NewJyucyu_Play2.4.6/)
--- (Running the application, auto-reloading is enabled) ---
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js.
[error] p.c.s.n.PlayRequestHandler - Exception caught in Netty
java.lang.NoClassDefFoundError: Could not initialize class play.api.http.DefaultHttpErrorHandler$
at play.core.server.Server$class.logExceptionAndGetResult$1(Server.scala:45)
at play.core.server.Server$class.getHandlerFor(Server.scala:65)
at play.core.server.NettyServer.getHandlerFor(NettyServer.scala:47)
at play.core.server.netty.PlayRequestHandler.handle(PlayRequestHandler.scala:82)
at play.core.server.netty.PlayRequestHandler.channelRead(PlayRequestHandler.scala:163)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:278)
at com.typesafe.netty.http.HttpStreamsHandler.channelRead(HttpStreamsHandler.java:129)
at com.typesafe.netty.http.HttpStreamsServerHandler.channelRead(HttpStreamsServerHandler.java:96)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292)
###該当のソースコード
【play2.4で必要なDB関連設定ファイル】
設定ファイル1. application.conf・・・DB関連、初期化情報設定ファイル
以下設定内容を抜粋
##DBコネクションプール設定
Database Connection Pool
https://www.playframework.com/documentation/latest/SettingsJDBC
~~~~~
Play doesn't require a JDBC database to run, but you can easily enable one.
libraryDependencies += jdbc
play.db {
The combination of these two settings results in "db.default" as the
#default JDBC pool:
config = "db"
default = "default"
Play uses HikariCP as the default connection pool. You can override
settings by changing the prototype:
prototype {
Sets a fixed JDBC connection pool size of 50
hikaricp.maximumPoolSize = 50
}
}
JDBC Datasource
https://www.playframework.com/documentation/latest/JavaDatabase
https://www.playframework.com/documentation/latest/ScalaDatabase
~~~~~
Once JDBC datasource is set up, you can work with several different
database options:
Slick (Scala preferred option): https://www.playframework.com/documentation/latest/PlaySlick
JPA (Java preferred option): https://playframework.com/documentation/latest/JavaJPA
EBean: https://playframework.com/documentation/latest/JavaEbean
Anorm: https://www.playframework.com/documentation/latest/ScalaAnorm
db {
You can declare as many datasources as you want.
By convention, the default datasource is named default
##DB設定情報
default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
default.url="jdbc:jtds:sqlserver:172.31.**.;databaseName=TEST"
default.username="sa"
default.password="c3@12345678"
default.logStatements=true
You can turn on SQL logging for any datasource
https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
#default.logSql=true
}
設定ファイル2. build.sbt・・・SQLServerドライバの動的取得設定
下記設定はデフォルトに近いですが、
1か所 "net.sourceforge.jtds" % "jtds" % "1.3.1"を追記
name := """テストプロジェクト"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.7"
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
"net.sourceforge.jtds" % "jtds" % "1.3.1"
)
###試したこと
課題に対してアプローチしたことを記載してください
1.Play framework バージョンを下げる
2.5 ⇒ 2.4 に下げ再テスト
(結果)同じ上記エラー
2.ドライバの変更
jtds-1.3.1.jar ⇔ sqljdbc4.jar(マイクロソフトのサイト)
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
上記にある通り
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。