Did you know

HOW TO CONNECT TO CAC DATABASE SERVER USING MySQL

May 22, 2013

In some projects, it is quite interesting to access to the CAC database for 3rd party apps integration purposes or just to check out the information stored in the database.

INTRODUCTION

In some projects, it is quite interesting to access to the CAC database for 3rd party apps integration purposes or just to check out the information stored in the database.

In this application note we are going to introduce some tools which may be useful to achieve this:

  • CAC DB_Manager
  • HeidiSQL (Any other SQL-Client would be also valid)

 

TECHNICAL TERMS


Database:

A database is an organized collection of data. In our case, the database is the group of data tables which include information about all Users, Doors, Profiles, etc. and all their corresponding univoque features such as door-number or User-ID.

In CAC, the database is stored in a file called “bdmds”

 

Database Management System: (DBMS)

A Database Management Systems (DBMS) is a set of programs that enables storing, modifying, and extracting information from a database. It also provides users with tools to add, delete, access, modify, and analyze data stored in one location. It is frequently called “Database Engine”.

Well known DBMSs include Oracle, FoxPro, Microsoft Access, Microsoft SQL Server, Paradox, MySQL, SQLite, etc. A database is not generally portable across different DBMS, but different DBMSs can inter-operate to some degree by using standards like SQL to support a single application built over more than one database.

In CAC, the Database Engine used is MySQL

 

 

CAC DB_MANAGER

CAC DB_Manager is just a software which will be useful to generate the corresponging permissions to access to the CAC Database. The software is available on the following link (Direct Download):

http://docweb.fermax.com/docs/techchannel/TEX_CAC_DBManager.zip

 

Requirements:

  •   CAC Database Server 1.6 (or higher) installed and running.
  •   No others MySQL instances running at the same time.
  •   Java JRE version 1.6 (or higher).
  •   No installation required.

Contents:

 

HOW TO USE

1.- Unzip the file to a known folder.

2.- Double click in 

3.- The software will connect to the database

4.- If the software has been launched properly, the following form will be shown:

5.- Enter a valid user: from 3 to 15 alphabetic characters and click on “Create New User” and “Yes

6.- A User-key (password) will be generated. Write it down and avoid that 3rd persons may note this key.

7.- The software will ask about creating another user. Select “Yes” to continue or “No” to exit.

NOTE: This password is different and univoque for each user. It is generated using an algorithm that includes the username and some features of the own PC. Therefore, this key will be different if we execute the software in different computers.

NOTE: In case we create another user with the same name, this will overwrite the previous one.

 

At this point, we have created a new user to manage the CAC database. In our case:

  •  Username = “newuser” (Selected by the user)
  •  Password = “UfSwvHcD” (Generated by the software)

This user will have the following persimissions to manage the CAC Database using a MySQL Client:

  •   List registers and tables
  •   Insert new registers
  •   Modify existing registers manually
  •   Erase registers

This user will not be able to erase tables in order to respect the structure of the database, not getting the bdmds file corrupted by mistake.

 

Once a valid user has been created, we can connect to the database manually using a MySQL Client. In this article we will use HeidiSQL (Open Source) but you can use any other one

 

How to connect to the database:

First of all, we need to install a MySQL Client. On the following link, there is available a free one (HeidiSQL)

http://www.heidisql.com/download.php

Once we have launched the SQL Client, we will open a communication with the MySQL Server. It is important that the server is running, so do not forget to execute CAC Database Server

Selecting a specific table in the “bdmds” list, there is a TAB in which we can see its internal data format:

Selecting a specific table in the “bdmds” list, there is a TAB in which we can see the information stored:

 

How to create a back-up manually:

Using a SQL Client, we can save a back-up of our installation.

In general, a backup file in CAC is just a list of SQL sentences executed in MySQL server which:

  •   Creates the CAC tables (CREATE/ALTER TABLE sql commands)
  •   Adds the information we had stored (INSERT INTO sql commands)

1.- In HeidiSQL right-click on “bdmds” and “Export database as SQL”

2.-  Select a folder and name to save the Back-up. Set the options as per indicated in the following example:

3.-  The file created will be saved as .sql file. We cannot import this file into CAC Server but we can use HeidiSQL afterwards to import this file (which contains SQL sentences with the information of the whole installation), overwritting the existing database.

To import this back-up to the database, just doble-click on this file and select the MySQL connection as we did above:

Finally, in HeidiSQL you can execute this sql file. The sentences will be executed overwriting the existing databae and creating a new one with the information we had saved on this back-up.

 

 

CONCLUSIONS:

 

  • With CAC DB Manager Software we will be able to create a user in order to manage the CAC Database. This can be useful to debug any possible database fail as well as to integrate our CAC system with an existing database (3rd party apps integration).
  •  When we save a backup file in CAC, we are saving just a script of SQL sentences .These sentences are executed over the CAC database when we load this backup file.
  •  With a MySQL Client
    •  We can check the information stored on each table.
    •  We can modify parameters and registers in the database manually.
    •  We can save the database as a .sql file, which is similar to a .cac file (backup).
    •  We can execute a .cac or a .sql file to restore a database manually in our CAC Softwares.

 

You can download the full application note on the following link:

http://docweb.fermax.com/docs/techchannel/TEX_APNOTE_MySQL_CAC.zip

For any further assistance, do not hesitate to contact FERMAX Technical department.