mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
ADD: Db2 container support
This commit is contained in:
@@ -20,8 +20,10 @@ public class DB2Platform extends DatabasePlatform {
|
||||
public DB2Platform() {
|
||||
super();
|
||||
this.platform = Platform.DB2;
|
||||
this.maxTableNameLength = 18;
|
||||
this.maxConstraintNameLength = 18;
|
||||
// Note: DB2 (at least LUW supports length up to 128)
|
||||
// TOOD: Check if we need to introduce a new platform (DB2_LUW_11 ?)
|
||||
this.maxTableNameLength = 128;
|
||||
this.maxConstraintNameLength = 128;
|
||||
this.truncateTable = "truncate table %s reuse storage ignore delete triggers immediate";
|
||||
this.sqlLimiter = new Db2SqlLimiter();
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package io.ebean.test.config.platform;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
class Db2Setup implements PlatformSetup {
|
||||
|
||||
@Override
|
||||
public Properties setup(Config config) {
|
||||
|
||||
config.ddlMode("dropCreate");
|
||||
config.setDefaultPort(50000);
|
||||
config.setUsernameDefault();
|
||||
config.setPasswordDefault();
|
||||
config.setUrl("jdbc:db2://localhost:${port}/${databaseName}");
|
||||
config.setDriver("com.ibm.db2.jcc.DB2Driver");
|
||||
config.datasourceDefaults();
|
||||
|
||||
return dockerProperties(config);
|
||||
}
|
||||
|
||||
private Properties dockerProperties(Config dbConfig) {
|
||||
|
||||
if (!dbConfig.isUseDocker()) {
|
||||
return new Properties();
|
||||
}
|
||||
|
||||
dbConfig.setDockerVersion("11.5.6.0a");
|
||||
return dbConfig.getDockerProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupExtraDbDataSource(Config config) {
|
||||
// not supported yet
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ public class PlatformAutoConfig {
|
||||
KNOWN_PLATFORMS.put("clickhouse", new ClickHouseSetup());
|
||||
KNOWN_PLATFORMS.put("cockroach", new CockroachSetup());
|
||||
KNOWN_PLATFORMS.put("hana", new HanaSetup());
|
||||
KNOWN_PLATFORMS.put("db2", new Db2Setup());
|
||||
}
|
||||
|
||||
private final DatabaseConfig config;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package main;
|
||||
|
||||
import io.ebean.docker.commands.Db2Config;
|
||||
import io.ebean.docker.commands.Db2Container;
|
||||
|
||||
public class StartDb2 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Db2Config config = new Db2Config("11.5.6.0a");
|
||||
config.setDbName("unit");
|
||||
config.setUser("unit");
|
||||
config.setPassword("unit");
|
||||
|
||||
// to change collation, charset and other parameters like pagesize:
|
||||
config.setCreateOptions("USING CODESET UTF-8 TERRITORY DE COLLATE USING IDENTITY PAGESIZE 32768");
|
||||
config.setConfigOptions("USING STRING_UNITS CODEUNITS32");
|
||||
|
||||
Db2Container container = new Db2Container(config);
|
||||
container.startWithDropCreate();
|
||||
}
|
||||
}
|
||||
@@ -181,9 +181,9 @@ datasource.nuodb.password=test
|
||||
datasource.nuodb.url=jdbc:com.nuodb://localhost/testdb
|
||||
#datasource.nuodb.driver=com.nuodb.jdbc.Driver
|
||||
|
||||
datasource.db2.username=db2admin
|
||||
datasource.db2.password=veryverysecret#1234
|
||||
datasource.db2.url=jdbc:db2://127.0.0.1:50000/SAMPLE
|
||||
datasource.db2.username=unit
|
||||
datasource.db2.password=test
|
||||
datasource.db2.url=jdbc:db2://127.0.0.1:50000/unit
|
||||
#datasource.db2.driver=com.ibm.db2.jcc.DB2Driver
|
||||
|
||||
datasource.hana.username=EBEAN_TEST
|
||||
|
||||
Reference in New Issue
Block a user