There can be cases in which one application requires to connect to multiple databases. By default each Zone in SFS2X exposes a single DBManager object but we can create more of these via code, to manage multiple data sources.
We highly recommend to create all of the required DBManager instances in the init() method of your Extension. This is an example of how to create a DBManager via code:
public class MultiDBExtension extends SFSExtension { private SFSDBManager dbm; @Override public void init() { // Prepare DBManager configuration DBConfig cfg = new DBConfig(); cfg.active = true; cfg.driverName = "com.mysql.jdbc.Driver"; cfg.connectionString = "jdbc:mysql://127.0.0.1/database_name"; cfg.userName = "db_user_name"; cfg.password = "db_user_pass"; cfg.testSql = "SELECT name FROM some_table LIMIT 1"; //... more settings ... // Create DBManager dbm = new SFSDBManager(cfg); } }
For more details you can check tha server side Javadoc: