Skip to content

Commit d17d72c

Browse files
committed
simplification of examples, keep only one for invocation from Java and one with studio_integration
1 parent fd54a2c commit d17d72c

File tree

15 files changed

+32
-591
lines changed

15 files changed

+32
-591
lines changed

README.DB2.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
## Build the sample
44

5-
Samples [advanced_queries](examples/advanced_queries), [embedded_in_dat](examples/embedded_in_dat) and
6-
[studio_integration](examples/studio_integration) do not need to be compiled, so you can skip this
5+
Sample [studio_integration](examples/studio_integration) do not need to be compiled, so you can skip this
76
section.
87

98
Before you build the [oil](examples/oil) sample, you must edit `build.properties` for the appropriate path locations:
@@ -52,13 +51,6 @@ to your DB2 jdbc driver.
5251
Depending on the sample you run, you need to edit `build.properties` to make
5352
`db2.jdbc.connector.path` point to your DB2 jdbc driver (i.e. db2jcc4.jar).
5453

55-
On samples like [advanced_queries](examples/advanced_queries), [embedded_in_dat](examples/embedded_in_dat),
56-
you will need to edit your `.dat` so that the following line points to where your jdbc driver resides:
57-
58-
```
59-
IloOplImportJava("../../external_libs/db2jcc4.jar")
60-
```
61-
6254
In sample [studio_integration](examples/studio_integration), you will need to edit `jdbc.js` to point
6355
to your jdbc driver, *or* add an `OPL_JDBC_DRIVER` environment variable pointing to it:
6456

README.MySQL.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
## Build the sample
44

5-
Samples [advanced_queries](examples/advanced_queries), [embedded_in_dat](examples/embedded_in_dat) and
6-
[studio_integration](examples/studio_integration) do not need to be compiled, so you can skip this
5+
Sample [studio_integration](examples/studio_integration) do not need to be compiled, so you can skip this
76
section.
87

98
Before you build the [oil](examples/oil) sample, you must edit `build.properties` for the appropriate path locations:
@@ -64,12 +63,6 @@ in your MySQL Connector/J extracted diretory)
6463
Depending on the sample you run, you need to edit `build.properties` to make
6564
`mysql.jdbc.connector.path` point to your MySQL jdbc driver (i.e. mysql-connector-java-5.1.40-bin.jar).
6665

67-
On samples like [advanced_queries](examples/advanced_queries), [embedded_in_dat](examples/embedded_in_dat),
68-
you will need to edit your `.dat` so that the following line points to where your jdbc driver resides:
69-
70-
```
71-
IloOplImportJava("../../external_libs/mysql-connector-java-5.1.40-bin.jar")
72-
```
7366

7467
In sample [studio_integration](examples/studio_integration), you will need to edit `jdbc.js` to point
7568
to your jdbc driver, *or* add an `OPL_JDBC_DRIVER` environment variable pointing to it:

README.SQLServer.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
## Build the sample
44

5-
Samples [advanced_queries](examples/advanced_queries), [embedded_in_dat](examples/embedded_in_dat) and
6-
[studio_integration](examples/studio_integration) do not need to be compiled, so you can skip this
5+
Sample [studio_integration](examples/studio_integration) do not need to be compiled, so you can skip this
76
section.
87

98
Before you build the [oil](examples/oil) sample, you must edit `build.properties` for the appropriate path locations:
@@ -42,13 +41,6 @@ look like `mssql-jdbc-7.2.2.jre8.jar`.
4241
Depending on the sample you run, you need to edit `build.properties` to make
4342
`sqlserver.jdbc.connector.path` point to your MSSQL server jdbc driver (i.e. mssql-jdbc-7.2.2.jre8.jar).
4443

45-
On samples like [advanced_queries](examples/advanced_queries), [embedded_in_dat](examples/embedded_in_dat),
46-
you will need to edit your `.dat` so that the following line points to where your jdbc driver resides:
47-
48-
```
49-
IloOplImportJava("../../external_libs/mssql-jdbc-7.2.2.jre8.jar")
50-
```
51-
5244
In sample [studio_integration](examples/studio_integration), you will need to edit `jdbc.js` to point
5345
to your jdbc driver, *or* add an `OPL_JDBC_DRIVER` environment variable pointing to it:
5446

README.md

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ This example will work with any 12.x OPL version, even if it is configured to ru
1515

1616
## Table of Contents
1717
- [Prerequisites](#prerequisites)
18-
- [Build and run the sample from java](#build-and-run-the-sample-from-java)
18+
- [Build and run the sample](#build-and-run-the-sample)
19+
- [Run the 'oil' sample](#run-the-oil-sample)
1920
- [Run the sample from OPL](#run-the-sample-from-opl)
20-
- [Reusing the sample with other databases](#reusing-the-sample-with-other-databases)
2121
- [Export plain dat files](#export-plain-dat-files)
2222
- [Run with another OPL version](#run-with-another-opl-version)
2323
- [License](#license)
@@ -43,76 +43,25 @@ This example will work with any 12.x OPL version, even if it is configured to ru
4343

4444
## Build and run the sample
4545

46-
The default sample uses model and data from [examples/oil](examples/oil).
4746
Before you run, you need to populate the database. See details in subsections:
4847

4948
- [Run sample with DB2](README.DB2.md)
5049
- [Run sample with MySQL](README.MySQL.md)
5150
- [Run sample with MS SQL Server](README.SQLServer.md)
5251

52+
### Run the 'oil' sample
53+
54+
The [examples/oil](examples/oil) sample demonstrates how to create a Java application with
55+
a custom data source and invoke OPL from Java.
5356

5457
### Run the sample from OPL
5558

56-
Sample in [examples/ilo_opl_call_java](examples/ilo_opl_call_java) shows how to
59+
The [examples/studio_integration](examples/studio_integration) sample shows how to
5760
use the jdbc custom data source as a library, without having the need to
5861
invoke OPL runtime from java. You can use this method to access database
5962
using a jdbc-custom-data-source from `oplrun` or OPL Studio.
6063

6164

62-
### Reusing the sample with other databases
63-
64-
As the sample is build on JDBC, it's possible to reuse <code>JdbcCustomDataSource</code> with minimal changes:
65-
66-
* Add your JDBC driver in your classpath
67-
* update db.xml with your database connection string
68-
69-
``` XML
70-
<!-- The connection string
71-
The default url connects to mysql on default port, using database
72-
'custom_data_source'
73-
-->
74-
<url>jdbc:mysql://localhost:3306/custom_data_source?useSSL=false</url>
75-
76-
<!-- Your connection credentials -->
77-
<user>sql_user</user>
78-
<password>mysql</password>
79-
```
80-
81-
* update db.xml with queries to read your data elements.
82-
83-
```XML
84-
<read>
85-
<query name="Gasolines">SELECT NAME FROM GasData</query>
86-
<query name="Oils">SELECT NAME FROM OilData</query>
87-
<query name="GasData">SELECT * FROM GasData</query>
88-
<query name="OilData">SELECT * FROM OilData</query>
89-
</read>
90-
```
91-
92-
* update db.xml with your output data elements mapping to tables.
93-
94-
```XML
95-
<write>
96-
<!-- This maps the output dataset "Result" to the "result" table -->
97-
<table name="Result" target="result"/>
98-
</write>
99-
```
100-
* Initialize a new <code>JdbcCustomDataSource</code>, read your database
101-
configuration file and add your data source to OPL using
102-
<code>IloOplModel.addDataSource()</code>.
103-
104-
```Java
105-
JdbcConfiguration jdbcProperties = null;
106-
String jdbcConfigurationFile = cl.getPropertiesFileName();
107-
if (jdbcConfigurationFile != null) {
108-
jdbcProperties = new JdbcConfiguration();
109-
jdbcProperties.read(jdbcConfigurationFile);
110-
// Create the custom JDBC data source
111-
IloOplDataSource jdbcDataSource = new JdbcCustomDataSource(jdbcProperties, oplF, def);
112-
// Pass it to the model.
113-
opl.addDataSource(jdbcDataSource);
114-
}
115-
```
11665

11766
## Export plain dat files
11867
* When running the `ant` command with the DB2/mysql target, simply add `-Dexport=result.dat` on the command line, and it will export all the tuplesets that have been extracted from the database to `result.dat` file.

examples/advanced_queries/README.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

examples/advanced_queries/build.xml

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/advanced_queries/oil.dat

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)