本文整理汇总了Java中com.avaje.ebean.config.ServerConfig.setDataSourceConfig方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConfig.setDataSourceConfig方法的具体用法?Java ServerConfig.setDataSourceConfig怎么用?Java ServerConfig.setDataSourceConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.avaje.ebean.config.ServerConfig
的用法示例。
在下文中一共展示了ServerConfig.setDataSourceConfig方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureDbConfig
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
@Override
public void configureDbConfig(ServerConfig config) {
Validate.notNull(config, "Config cannot be null");
DataSourceConfig ds = new DataSourceConfig();
ds.setDriver(configuration.getString("database.driver"));
ds.setUrl(configuration.getString("database.url"));
ds.setUsername(configuration.getString("database.username"));
ds.setPassword(configuration.getString("database.password"));
ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation")));
if (ds.getDriver().contains("sqlite")) {
config.setDatabasePlatform(new SQLitePlatform());
config.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
}
config.setDataSourceConfig(ds);
}
示例2: SQLOfflineTeamHandler
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public SQLOfflineTeamHandler()
{
ServerConfig config = new ServerConfig();
config.setDataSourceConfig(MWAPI.getConfig().getDataSourceConfig());
config.addClass(BasicTeam.class);
server = EbeanServerFactory.create(config);
try
{
server.find(BasicTeam.class).findRowCount();
}
catch (Exception e)
{
DdlGenerator gen = ((DefaultServer) server).getDdlGenerator();
gen.runScript(true, gen.generateCreateDdl());
}
}
示例3: SQLOfflineGameHandler
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public SQLOfflineGameHandler()
{
ServerConfig config = new ServerConfig();
config.setDataSourceConfig(MWAPI.getConfig().getDataSourceConfig());
config.addClass(BasicGame.class);
config.addClass(MapScalarTypeConverter.class);
server = EbeanServerFactory.create(config);
try
{
server.find(BasicGame.class).findRowCount();
}
catch (Exception e)
{
DdlGenerator gen = ((DefaultServer) server).getDdlGenerator();
gen.runScript(true, gen.generateCreateDdl());
}
}
示例4: SQLOfflineUserHandler
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public SQLOfflineUserHandler()
{
ServerConfig config = new ServerConfig();
config.setDataSourceConfig(MWAPI.getConfig().getDataSourceConfig());
config.addClass(BasicUser.class);
server = EbeanServerFactory.create(config);
try
{
server.find(BasicUser.class).findRowCount();
}
catch (Exception e)
{
DdlGenerator gen = ((DefaultServer) server).getDdlGenerator();
gen.runScript(true, gen.generateCreateDdl());
}
}
示例5: adaptFrom
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourceConfig dsConfig, SqlDbService svc) {
ServerConfig config = new ServerConfig();
config.setName(svc.id());
config.setDataSourceConfig(adaptFrom(dsConfig, svc));
config.setDdlGenerate(actConfig.ddlGeneratorConfig.create);
config.setDdlRun(actConfig.ddlGeneratorConfig.create);
config.setDdlCreateOnly(!actConfig.ddlGeneratorConfig.drop);
config.setNamingConvention(namingConvention(actConfig));
Set<Class> modelClasses = svc.modelClasses();
if (null != modelClasses && !modelClasses.isEmpty()) {
for (Class modelClass : modelClasses) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(S.concat("add model class into Ebean config: ", modelClass.getName()));
}
config.addClass(modelClass);
}
}
return config;
}
示例6: configureDbConfig
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public void configureDbConfig(ServerConfig config) {
Validate.notNull(config, "Config cannot be null");
DataSourceConfig ds = new DataSourceConfig();
ds.setDriver(configuration.getString("database.driver"));
ds.setUrl(configuration.getString("database.url"));
ds.setUsername(configuration.getString("database.username"));
ds.setPassword(configuration.getString("database.password"));
ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation")));
if (ds.getDriver().contains("sqlite")) {
config.setDatabasePlatform(new SQLitePlatform());
config.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
}
config.setDataSourceConfig(ds);
}
示例7: InMemoryEbeanServer
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public InMemoryEbeanServer() {
// Create in-memory database configuration.
DataSourceConfig dbConfig = new DataSourceConfig();
dbConfig.setUsername("sa");
dbConfig.setPassword("");
dbConfig.setUrl("jdbc:h2:mem:tests2;DB_CLOSE_DELAY=-1");
dbConfig.setDriver("org.h2.Driver");
ServerConfig config = new ServerConfig();
config.setName("h2");
config.setDataSourceConfig(dbConfig);
config.setDefaultServer(true);
for (Class<?> entity : EbeanEntities.getEntities()) {
config.addClass(entity);
}
config.setDdlGenerate(true);
config.setDdlRun(true);
server = EbeanServerFactory.create(config);
ddl = ((SpiEbeanServer) server).getDdlGenerator();
}
示例8: createEbeanServerInstance
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public EbeanServer createEbeanServerInstance(PluginDataResolver pluginDataResolver) {
File myDataDir;
try {
myDataDir = new File(pluginDataResolver.getPluginDatabaseDirectory());
} catch (IOException e) {
Loggers.SERVER.error("tcDebRepository EbeanServerProvider : Failed to get database directory location");
Loggers.SERVER.debug(e);
return null;
}
if (myDataDir.exists() && myDataDir.isDirectory() && myDataDir.canWrite()) {
ServerConfig config = new ServerConfig();
config.setName("db");
config.loadFromProperties();
DataSourceConfig dsConfig = config.getDataSourceConfig();
dsConfig.setUrl(
"jdbc:h2:file:" + myDataDir.getAbsolutePath() + File.separator + "tcDebRepositoryDB;DB_CLOSE_ON_EXIT=FALSE");
config.setDataSourceConfig(dsConfig);
Loggers.SERVER.debug(config.getDataSourceConfig().getUsername());
// set as default and register so that Model can be
// used if desired for save() and update() etc
config.setDefaultServer(true);
config.setRegister(true);
config.addPackage("debrepo.teamcity.ebean");
Loggers.SERVER.debug("EbeanServerProvider :: ebean Properties are: " + config.getProperties().toString());
return EbeanServerFactory.create(config);
}
return null;
}
示例9: createServerConfig
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public static ServerConfig createServerConfig(DataSourceFactory dbConfig) {
ServerConfig config = new ServerConfig();
config.setName("main");
config.setDataSourceConfig(createDataSourceConfig(dbConfig));
config.setDefaultServer(true);
EbeanEntities.getEntities().forEach(config::addClass);
return config;
}
示例10: configureDbConfig
import com.avaje.ebean.config.ServerConfig; //导入方法依赖的package包/类
public void configureDbConfig(ServerConfig config) {
DataSourceConfig ds = new DataSourceConfig();
ds.setDriver(configuration.getString("database.driver"));
ds.setUrl(configuration.getString("database.url"));
ds.setUsername(configuration.getString("database.username"));
ds.setPassword(configuration.getString("database.password"));
ds.setIsolationLevel(TransactionIsolation.getLevel(configuration.getString("database.isolation")));
if (ds.getDriver().contains("sqlite")) {
config.setDatabasePlatform(new SQLitePlatform());
config.getDatabasePlatform().getDbDdlSyntax().setIdentity("");
}
config.setDataSourceConfig(ds);
}