Below are the steps required to set up the MySQL example: create and fill a test database, and deploy and undeploy the service.

Creating and filling in the database

To run the example, a test database should be created in your MySQL installation, containing the correct schema and data. One way of doing this is to execute the SQL script included in the examples:

Configuring MySQL
$ mysql -u root -p < examples/src/com/opencloud/slee/example/dbquery/MySqlTestDB.sql
examples/src/com/opencloud/slee/test/dbquery/MySqlTestDB.sql
CREATE DATABASE mappings;
CREATE USER 'appuser' IDENTIFIED BY 'appuser';
GRANT ALL PRIVILEGES ON mappings.* TO 'appuser';
FLUSH PRIVILEGES;
USE mappings;

DROP TABLE IF EXISTS mappings;

CREATE TABLE mappings (
  short_code VARCHAR(10) PRIMARY KEY,
  long_code VARCHAR(64) NOT NULL
);

INSERT INTO mappings (short_code, long_code) VALUES ('0000', '11111111111');
COMMIT;

DROP PROCEDURE IF EXISTS extend_long_code_with_prefix;

DELIMITER //
CREATE PROCEDURE EXTEND_LONG_CODE_WITH_PREFIX(
    OUT p_concat VARCHAR(64),
    IN p_short_code VARCHAR(10),
    IN p_prefix VARCHAR(64))
BEGIN
    SELECT concat(p_prefix, long_code)
      INTO p_concat
      FROM mappings
     WHERE short_code = p_short_code;

    UPDATE mappings
       SET long_code = p_concat
     WHERE short_code = p_short_code;
END //
DELIMITER ;
Warning The same host, database, user, and password must be set in examples/build.properties.

Deploying the example service

First, mysql.jdbc.dir and client.home must be set in the build.properties and examples/build.properties files respectively.

The build target deploy-mysql-example of examples/mysql.build.xml will deploy the DB Query RA, the Example RA, and the example service.

Undeploying the example service

The build target undeploy-mysql-example of examples/mysql.build.xml will undeploy the example service, the DB Query RA, and the Example RA.

Previous page