chespinoza
chespinoza

Reputation: 2658

Play 2.0 - Scala - How Add dependencies for any JDBC Drivers

can somebody tell me how can I add a MSSQL driver dependence to a Play 2 App?

I have this settings working...

db.default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
db.default.url="jdbc:sqlserver://127.0.0.1:1433;databaseName=test;user=test;password=test;"

Edited: I know that in the file project/Build.scala must be the statement for this with a line like this:

val appDependencies = Seq(
"" % "" % ""
)

But I don't know how must be filled these strings and I would like know that to be able to add any dependence type.

Upvotes: 1

Views: 2925

Answers (2)

pedrofurla
pedrofurla

Reputation: 12783

Unfortunately, it seems that there are no repositories with the MSSQL JDBC drivers.

In this case, the correct, most reliable solution would be to put the .jars in the lib folder, this is what SBT calls "unmanaged dependency folder". Since there isn't a central place for this driver I'd also commit this jar along with the rest of the project in VCS.

Upvotes: 8

biesior
biesior

Reputation: 55798

You don't need to write anything in project/Build.scala

  1. Download and save Microsoft's driver (probably sqljdbc4.jar) in the lib folder (if you didn't it yet).
  2. Configure connection in the application.conf (sample working for me with Azure)

    db.default.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
    db.default.url="jdbc:sqlserver://sOm3s3rVeR.database.windows.net:1433;database=your-db;encrypt=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30"
    db.default.user="account@sOm3s3rVeR"
    db.default.password="YOURpass123"
    
    # don't forget to uncomment that line: 
    ebean.default="models.*"
    

And that's all. Anyway I remember that I had some problems with Ebean 2.7.3 (default in Play 2.0.4) so I went with 2.7.5. Now it works.

Upvotes: 0

Related Questions