Menu

Manual ScadaBR English 8 Chapter 8 Log in to Edit

blackfox

8. Tips

8.1. How to change the database from Derby to MySQL

ScadaBR currently supports three DataBase Management Systems (DMBS): MySQL, PostgreSQL and Derby.
The file ScadaBR.war comes standard configured with Derby for reasons of user friendliness because it requires no embedded DBMS installation or configuration parameters like username and password.

  • Note 1: There is a conversion mechanism between Derby and MySQL. ScadaBR ships with a conversion utility that automatically will copy your data from Derby to a fresh MySQL schema (and theoretically in the other direction as well).
  • Note 2: Your MySQL user and the schema (or catalog) must already exist, and the user must have permission to the schema in all the usual ways. (When in doubt, grant the user all permissions to the schema). But, do not create the ScadaBR tables yourself, ScadaBR likes to do that itself.
  • Note 3: In <tomcat-webapps>/<ScadaBR_home>/WEB-INF/classes/ you will find several env.properties.xxxxx files with example setiings for Derby, MySQL and PostgreSQL.

Choose one of the two possibilities: 8.1.1. or 8.1.2.

8.1.1. With ScadaBR already Installed

Edit the <tomcat-webapps>/<ScadaBR_home>/WEB-INF/classes/env.properties file. By default the settings of concern will be:

    db.type=derby
    db.url=~/../../bin/scadabrDB
    db.username=
    db.password=

You will have existing "db." entries in there that point to the Derby database. Prepend these entries with "convert." They will then look something like this:

    convert.db.type=derby
    convert.db.url=~/../../bin/scadabrDB
    convert.db.username=
    convert.db.password=

Note: You may only have the "url" entry. This is fine.

Than add entries that point to your MySQL instance. The following are examples. Modify them to suit your environment.

    db.type=mysql
    db.url=jdbc:mysql://localhost/mango
    db.username=<mysql username>
    db.password=<mysql password>
    db.pool.maxActive=10
    db.pool.maxIdle=10

Note: The url to mysql will look something like this: db.url=jdbc:mysql://localhost/mango

Save the changes and restart ScadaBR.

Watch the console messages. You will be given information on the steps and progress of the conversion as it occurs. Depending on the size of your Derby database and the power of your hardware this process could take seconds or hours.

Note: If you have any problems during the conversion (e.g. a power failure, and error, etc), you can always restart the process by dropping all of the tables that ScadaBR created in your MySQL schema and restarting ScadaBR.

8.1.2. Edit ScadaBR.war before building

Unzip ScadaBR.war file to a directory <scadabr>. (You may rename the file toScadaBR.zip and then extract it).

Open with a text editor the file: <scadabr>/WEB-INF/classes/env.properties and edit it as follows.

    db.type=mysql
    db.url=jdbc:mysql://localhost/mango
    db.username=<mysql username>
    db.password=<mysql password>
    db.pool.maxActive=10
    db.pool.maxIdle=10

Save the file, compress the entire folder <scadabr> to ScadaBR.war again and perform the installation.