This tutorial describes how to connect to an Oracle database using Flexmonster Data Server – a special server developed by Flexmonster. This server communicates with the client using the custom data source API – our custom communication protocol allowing you to retrieve already aggregated data from a server to Flexmonster Pivot.
To download the Data Server, you will need Flexmonster CLI — a command-line interface tool for Flexmonster. If needed, install the CLI globally using npm:
npm install -g flexmonster-cli
After that, a new flexmonster
command will be available in the console. Learn more about Flexmonster CLI and its commands in our documentation.
Now follow the steps below to connect to Oracle using the Data Server.
If Flexmonster is not yet embedded, set up an empty component in your webpage:
Complete the Quick start guide. Your code should look similar to the following example:
let pivot = new Flexmonster({
container: "pivotContainer",
toolbar: true
});
Complete the Integration with Angular guide. Your code should look similar to the following example:
<fm-pivot
[toolbar]="true">
</fm-pivot>
Complete the Integration with React guide. Your code should look similar to the following example:
<FlexmonsterReact.Pivot
toolbar={true}
/>
Complete the Integration with Vue guide. Your code should look similar to the following example:
<Pivot
ref="pivot"
toolbar>
</Pivot>
The previous step demonstrated how to configure Flexmonster Pivot. Now it’s time to set up Flexmonster Data Server.
Get the Data Server with the following CLI command:
flexmonster add fds -r
The flexmonster add fds
command does the following:
.zip
archive with Flexmonster Data Server.flexmonster-data-server/
folder will appear in your working directory.The -r
option, which is short for --run
, installs the Data Server as a Windows/Unix service and then runs it. Besides, it installs and runs Flexmonster Admin Panel – a graphical user interface for the Data Server.
Now follow the steps below to connect the Data Server to your database.
Now let’s create a new index for your data.
Open Flexmonster Admin Panel and go to Indexes > Add New Index. Then, fill in the following fields:
Database
.Oracle
.0
, which means the Data Server will not reload the data.Your configurations should look similar to the following:
Note that ORCL
is a variable defined in the tnsnames.ora file. For example:
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
When the index configuration is complete, click Create. The index will be automatically added to your index pool.
On the client side, the report should be configured as follows:
var pivot = new Flexmonster({
container: "pivotContainer",
toolbar: true,
report: {
dataSource: {
type: "api",
url: "http://localhost:9500",
index: "index-database"
}
}
});
Note The index
must match the name of the index defined in step 3 (e.g., "index-database"
).
When Flexmonster Pivot requests the data, Flexmonster Data Server sends the response and then caches it. In case the component sends the same request once again, the server responds with the data from its cache. The Data Server clears the cache when restarted.
The Data Server’s cache has a memory limit. When the cache does not have enough memory for a new response, the Data Server server deletes one of the previously cached responses.
Note You can manage the cache size via the Cache size limit configuration.
Follow the steps below to call a stored procedure in the Data Server:
Step 1. Create a stored procedure.
Step 2. When adding a new index, call the stored procedure in the Query property:
call storedProcedure()
Learn more about calling stored procedures in Oracle.
Note Stored procedures allow executing any valid SQL query from the Data Server. To avoid unauthorized access to the database, create a database user with read-only access rights and specify this user in the connection string.
You may be interested in the following articles: