@@ -31,18 +31,31 @@ public class JdbcCustomDataSource extends IloCustomOplDataSource {
3131 /**
3232 * Adds a custom data source to a model.
3333 *
34- * @param configXml The xml configuration for the data source
34+ * @param xmlFile The xml configuration for the data source
3535 * @param model The OPL Model
3636 */
37- public static void addDataSource (String configXml , IloOplModel model ) throws IOException {
37+ public static void addDataSourceXMLConfig (String xmlFile , IloOplModel model ) throws IOException {
3838 JdbcConfiguration config = new JdbcConfiguration ();
39- config .read (configXml );
39+ config .read (xmlFile );
4040 IloOplFactory factory = IloOplFactory .getOplFactoryFrom (model );
4141 IloOplModelDefinition definition = model .getModelDefinition ();
4242 JdbcCustomDataSource source = new JdbcCustomDataSource (config , factory , definition );
4343 model .addDataSource (source );
4444 }
45-
45+
46+ /**
47+ * Adds a custom data source to a model.
48+ *
49+ * @param config The JDBC configuration object
50+ * @param model The OPL Model
51+ */
52+ public static void addDataSource (JdbcConfiguration config , IloOplModel model ) {
53+ IloOplFactory factory = IloOplFactory .getOplFactoryFrom (model );
54+ IloOplModelDefinition definition = model .getModelDefinition ();
55+ JdbcCustomDataSource source = new JdbcCustomDataSource (config , factory , definition );
56+ model .addDataSource (source );
57+ }
58+
4659 /**
4760 * Creates a new JDBC custom data source, based on the specified configuration.
4861 *
@@ -71,6 +84,7 @@ void fillNamesAndTypes(IloTupleSchema schema, String[] names, Type[] types) {
7184 * is generated.
7285 */
7386 public void customRead () {
87+ long startTime = System .currentTimeMillis ();
7488 System .out .println ("Reading elements from database" );
7589 Properties prop = _configuration .getReadQueries ();
7690 Enumeration <?> propertyNames = prop .propertyNames ();
@@ -80,7 +94,8 @@ public void customRead() {
8094 System .out .println ("Reading " + name + " using \" " + query + "\" " );
8195 customRead (name , query );
8296 }
83- System .out .println ("Done" );
97+ long endTime = System .currentTimeMillis ();
98+ System .out .println ("Done (" + (endTime - startTime )/1000.0 + " s)" );
8499 }
85100
86101 public void customRead (String name , String query ) {
0 commit comments