播放2.5框架和SQL Server 2008 R2连接

现在

我对Java和Play 2.5框架非常陌生,但是我想通过VPN连接到SQL Server 2008 R2数据库。

我下载了文件jtds-1.3.1-dist.zip,将其解压缩并复制到libexec文件夹中。

我在build.sbt文件中插入了这一行

val appDependencies = Seq(
"net.sourceforge.jtds" % "jtds" % "1.3.1"
)

这是application.conf文件:

## 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.minimumIdle = 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`

# https://www.playframework.com/documentation/latest/Developing-with-the-H2-Database
#default.driver = org.h2.Driver
#default.url = "jdbc:h2:mem:play"
#default.username = sa
#default.password = ""
default.url = "jdbc:jtds:sqlserver://xyz.aaa.bbb.global:1433/MyDB;instance=MSSQLSERVER"
default.driver = net.sourceforge.jtds.jdbc.Driver
default.username = username
default.password = "password"


# You can turn on SQL logging for any datasource
# https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
default.logSql=true
}

不幸的是,我总是得到这个错误:

无法连接到数据库[默认]

有人可以帮我吗。

现在

最后,我使用sqljdbc42.jar进行连接。我没有将任何行添加到build.sbt文件中,只是将jar添加到lib文件夹中,将这两行添加到application.conf文件中:

default.driver = com.microsoft.sqlserver.jdbc.SQLServerDriver default.url =“ jdbc:sqlserver://xxx.yyy.zzz.global:1433; databaseName = MyDB; user = uname; password = pword;”

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章