SQL Server
With SQL Server we have to decide if we are going to use the sqlserver17
or the default older one.
sqlserver17
To setup to use sqlserver17 we should set the databasePlatformName
to sqlserver17 at either the
ebean.databasePlatformName
> level or at ebean.test.sqlserver.databasePlatformName
> level.
ebean:
databasePlatformName: sqlserver17 ## only using sql server
test:
platform: sqlserver # h2, postgres, mysql, oracle, sqlserver
ddlMode: dropCreate # none | dropCreate | migrations
dbName: test
sqlserver:
#collation: SQL_Latin1_General_CP1_CS_AS ## use an explicit collation
#collation: default ## use the sql server default
When testing against multiple database platforms put databasePlatformName: sqlserver17
under sqlserver
like the example below:
ebean:
test:
platform: sqlserver # h2, postgres, mysql, oracle, sqlserver
ddlMode: dropCreate # none | dropCreate | migrations | create
dbName: test
sqlserver:
databasePlatformName: sqlserver17 ## put here when testing multiple platforms
#collation: SQL_Latin1_General_CP1_CS_AS ## use an explicit collation
#collation: default ## use the sql server default
The above will use the following defaults:
username: | {databaseName} |
---|---|
password: | SqlS3rv#r |
port: | 1433 |
url: | jdbc:sqlserver://localhost:{port};databaseName={databaseName} |
driver: | com.microsoft.sqlserver.jdbc.SQLServerDriver |
image: | microsoft/mssql-server-linux:{version} |
ebean-sqlserver dependency
We can use the io.ebean:ebean-sqlserver
dependency rather than io.ebean:ebean
if we want to only
bring in the SqlServer specific platform code. Depending on io.ebean:ebean
will bring in all platforms.
Docker container
We can programmatically start a docker container version of SqlServer.
The below uses ebean-test-docker
dependency which already comes with ebean-test
.
If we do not have a dependency on ebean-test
then add io.ebean:ebean-test-docker:5.0
as a dependency.
package main;
import io.ebean.docker.commands.SqlServerContainer;
public class Main {
public static void main(String[] args) {
SqlServerContainer container = SqlServerContainer.newBuilder("2019-CU15-ubuntu-20.04")
.dbName("my_app")
.collation("SQL_Latin1_General_CP1_CS_AS")
// .containerName("ut_sqlserver")
// .port(1433)
.build();
container.start();
}
}