The additional data store option can be used if the data source is known at development time as it is suggested to be updated in the properties file. However, I have an use case where teh database server, database name etc. will be defined at run-time. In that case, in traditional applications we can use JDBC driver to connect by providing the required information from an interface (e.g. Connection con = DriverManager.getConnection(connectionUrl, userId, userPassword)). Can this be done in CUBA application? Note that this connection would be in addition to the main data connection we will have in the project.
The data stores mechanism relies on the DataSource beans initialized at server startup, and CUBA won’t offer any specific means for changing database URLs at runtime. However, you can try to change the connection URL at runtime using Tomcat’s JMX beans controlling the data source - look for Catalina:type=DataSource,...
MBeans in JMX console.
Also, you can always use JDBC connections to any databases (as you mentioned), and map data to non-persistent (in terms of CUBA) entities manually.
Thank you Konstantin. For using JDBC connections, is there any CUBA specific resources/API should be used or it’s totally supporting pure JDBC APIs?
CUBA doesn’t restrict you in using JDBC.
1 Like