Connection to multiple dbs with same schema

21 views
Skip to first unread message

Alberto Anguita

unread,
Nov 18, 2015, 6:28:26 AM11/18/15
to ActiveJDBC Group
I want to work with several sqlite databases that have similar schema. I know that this might not be the most "correct" design, but I would just be working with a few fixed sqlite databases, one for each user, and I would like to have independent transactions.

Is is possible to do this in ActiveJDBC?

Regards.

Igor Polevoy

unread,
Nov 18, 2015, 5:36:48 PM11/18/15
to ActiveJDBC Group
It  is possible. Please read this article: 

Basically, the models in ActiveJDBC find a connection on current thread, and operate on that connection. This means that if you place a connection on thread that points to one database, then read a model from it, close connection, then open a connection  to a different database with the same schema, and save that same model, the second transaction will be sent to the second database. So long you have identical structure of related tables, it will work. 

This interesting feature makes it easy to use ActiveJDBC to write data migration programs. 

Thanks

Alberto Anguita

unread,
Nov 18, 2015, 7:25:26 PM11/18/15
to ActiveJDBC Group
Wow it is awesome. I had read the article but I had not understood the thread-based connection. I just tried, perfect. Thanks again.

Igor Polevoy

unread,
Nov 18, 2015, 7:57:16 PM11/18/15
to ActiveJDBC Group
glad it works for  you!
Reply all
Reply to author
Forward
0 new messages