Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with multiple-db configuration #14

Open
wangdanqing opened this issue Sep 22, 2017 · 3 comments
Open

Issue with multiple-db configuration #14

wangdanqing opened this issue Sep 22, 2017 · 3 comments

Comments

@wangdanqing
Copy link

wangdanqing commented Sep 22, 2017

i saw config about below:

# the database configuration
db.instances=mongo,sql
# db1 configurations
db.mongo.impl=act.db.morphia.MorphiaPlugin
db.mongo.uri=mongodb://localhost/myapp
db.sql.impl=act.db.ebean.EbeanPlugin
db.url=jdbc:h2:./myapp
db.ddl.createOnly=true

The db.mongo.uri should be changed to db.mongo.url

The other thing is I tried to configure mysql db along with mongo db config, however console throws h2 driver class not found exception.

@wangdanqing wangdanqing changed the title maybe there has a bug for multiple-db config, pls check you website doc maybe there has a bug for multiple-db config, pls check your website doc Sep 22, 2017
@wangdanqing
Copy link
Author

wangdanqing commented Sep 22, 2017

After changing uri to url, the app is able to start. However there is another problem found.

Here is my db.properties file:

db.instances=db1,db2

db.db1.impl=act.db.ebean.EbeanPlugin
db.db1.driver=com.mysql.jdbc.Driver
db.db1.url=jdbc:mysql://127.0.0.1:3306/test1
db.db1.username=root
db.db1.password=root

db.db2.impl=act.db.ebean.EbeanPlugin
db.db2.driver=com.mysql.jdbc.Driver
db.db2.url=jdbc:mysql://127.0.0.1:3306/test2
db.db2.username=root
db.db2.password=root

And the Java classes

@DB("db1")
@Entity(name = "va")
public class VirtualAccount{
	@Id
	private Long id;
	@Index(unique = true)
	public String ownerId;
	// balance in cents
	public int balance;
}
@DB("db2")
@Entity(name = "va2")
public class VirtualAccount2{
	@Id
	private Long id;
	@Index(unique = true)
	public String ownerId;
	// balance in cents
	public int balance;
}

After app started I found table va and va2 get created in both test1 and test2 database. Expected result is only va created in test1 and va2 only in test2

@greenlaw110 greenlaw110 changed the title maybe there has a bug for multiple-db config, pls check your website doc Issue with multiple-db configuration Sep 22, 2017
@greenlaw110
Copy link
Contributor

@wangdanqing what is the actframework version and what is ebean version?

@wangdanqing
Copy link
Author

<dependency>
    <groupId>org.actframework</groupId>
    <artifactId>act</artifactId>
    <version>1.4.12</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.actframework</groupId>
    <artifactId>act-ebean</artifactId>
    <version>1.0.2</version>
</dependency>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants