[opencms-dev] Run SQL script during module import

Michael Emmerich m.emmerich at alkacon.com
Wed Mar 2 15:24:27 CET 2011


Ignacio,

> Hi,
>
> Is there a way to run a sql script during module import? I created a
> module that uses 2 custom DB tables. I would like to be able to run a
> script that creates such tables during this module's import process in
> order to avoid having to create the tables manually before the import
> process. Is there a way to do such a thing?

What you can do is to implement a so called ModuleAction class. This is 
a Java class implementing the I_CmsModuleAction interface.

The easiest thing is to extend the A_CmsModuleAction class to do so.

In this class you have the

public void initialize(CmsObject adminCms, CmsConfigurationManager 
configurationManager, CmsModule module)

method.

This method is called during system startup (which is required after you 
add new java classes to OpenCms). In this method you could test if your 
required tables exist and if not create them.

You could take a look at the OAMP Counter module which can be found in 
the CVS, which is using this to create some DB tables.

Kind Regards,
Michael.
-- 
Kind Regards,
Michael.

-------------------
Michael Emmerich

Visit OpenCms Days 2011 Conference and Expo
May 9 to May 10 2011 in Cologne, Germany
http://www.opencms-days.org

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org



More information about the opencms-dev mailing list