Skip to content

Let ebean module support multiple named dataSources  #771

@thomasguo

Description

@thomasguo

Sometimes we need to connect to multiple databases within the same application. Currently with Jdbc
module we can do like this:

{
  use(new Jdbc("db.main"));
  use(new Jdbc("db.audit"));

  get("/db", req -> {
    DataSource maindb = require(DataSource.class);
    DataSource auditdb = require("db.audit", DataSource.class);
    // ...
  });
}

But with ebean module, we cannot name the EbeanServer bean on the same way. Currently Jooby just parses the url to 'guess' a database name, that makes it difficult to inject the ebeanserver via name. Why not we just use the Ebeanby's name as the datasource name?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions