问题描述
我正尝试在Play Framework中使用MSSQL服务器,在我的application.conf中
Am trying to use MSSQL server with Play Framework, In my application.conf
db.url=jdbc:microsoft:sqlserver://localhost\SQL2008:1433;DatabaseName=testDB
db.driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
db.user=sa
db.pass=sa
我收到以下错误提示
Database error
A database error occured : Cannot connected to the database, [Microsoft][SQLServer
2000 Driver for JDBC]Error establishing socket.
play.exceptions.DatabaseException: Cannot connected to the database, [Microsoft]
[SQLServer 2000 Driver for JDBC]Error establishing socket.
at play.db.DBPlugin.onApplicationStart(DBPlugin.java:132)
at play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:425)
at play.Play.start(Play.java:495)
at play.Play.detectChanges(Play.java:599)
at play.Invoker$Invocation.init(Invoker.java:186)
at Invocation.HTTP Request(Play!)
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error
establishing socket.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)
at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)
我已将sqljdbc4.jar添加到lib文件夹中.甚至尝试使用mssqlserver.jar,msutil.jar,msbase.jar
I have added sqljdbc4.jar to lib folder.even tried using mssqlserver.jar,msutil.jar,msbase.jar
推荐答案
对于在玩游戏的同时寻找MSSQL的人可能很有用.
May be useful for someone,looking for MSSQL along with play.
首先下载 jtds
将jtds jar文件复制到
copy jtds jar file to
play-1.2.3\framework\lib
以及您的应用程序lib文件夹
as well as your application lib folder
重新开始播放
在您的application.conf中
In your application.conf
# If you need a full JDBC configuration use the following :
db.url=jdbc:jtds:sqlserver://localhost:1433/testDB;instance=SQL2008
db.driver=net.sourceforge.jtds.jdbc.Driver
db.user=sa
db.pass=sa
开始播放:)
为Play2更新
像这样将播放依赖项添加到您的Build.scala
Add play dependencies to your Build.scala
like this
val appDependencies = Seq(
"net.sourceforge.jtds" % "jtds" % "1.2"
)
Play2中的conf
文件中有更改...
There is change in conf
file in Play2...
db.default.url="jdbc:jtds:sqlserver://localhost:1433/testDB;instance=SQL2008"
db.default.driver=net.sourceforge.jtds.jdbc.Driver
db.default.user=sa
db.default.pass=sa
重新开始播放SBT
将为您下载依赖项.开始播放:)
restart play SBT
will download dependencies for you. Start Playing :)
这篇关于PlayFramework MSSQL数据库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!