beautypg.com

Using mig calendar the correct way – MiG InfoCom MiG Calendar DBConnect Guide User Manual

Page 15

background image

MiG InfoCom AB

entities have been changed and one auto increase column that just
increases it's value for every new record.

This gives DBConnect the option to, in a very fast and resource slim
manner, ask the database which records has been created or updated
since change X. DBConnect handles everything automatically if it is
just fed the names and definition of those tables. See the example
code for how to do this.

To enable this feature create a

UpdateMapping

object and set it on

the

PropertyMappingList

. See

DBUtil.createUpdateTable(..)

for how these table should

be created.

Database Connection

DBConnect must be told how to connect to the database that it should
use for persisting activities and categories. This is done in a standard
JDBC manner with maximum of flexibility. The

ConnectionProvider

interface is used for the purpose. It is very

simple and only defines how to get/return a connection and a callback
method for when the provider isn't needed any more (.dispose()).

There is also a concrete implementation that will be sufficient for most
cases. It has connection pooling, pre- and/or post connection
verification with customizable SQL as well as maximum live
connection count. The implementation is in the class

PooledConnectionProvider

and how to use it can be view in

the example code.

Example Database Mapping

For versioning purposes the code is not pasted into this document.
During the installation of DBConnect the demo code installed. You can
view this code and use it as a reference.

Using MiG Calendar the Correct Way

Event Types

When you add or remove activities/categories from their respective
depository the event type that should be fired is passed along as an
argument. The reason for this that DBConnect must know if the
activity/category was removed because it wasn't needed in memory
anymore or if it was deleted by the user.

There are four event types and DBConnect reacts appropriately on

DBConnect Guide

Page 15 / 25