Xoetrope
HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Using the Hsqldb as a central database


Due to the triggering mechanism used by the Hsql database, classes implementing the required behaviour
after triggers are fired, have to be present in the classpath that is used to start the database.
The classes are contained in the com.xoetrope.service.replication.hsqldb package of XuiPro.

The next thing that needs to be done is to create and configure the NamedConnectionManager before
the Hsqdb server is started so that it exists in the same JVM as the server.
The NamedConnectionManager instance is used by the trigger classes to establish the required JDBC connections.

The server can be started with the following code.

package hsqlserver;

import java.util.logging.Level;
import java.util.logging.Logger;
import net.xoetrope.optional.data.XOptionalDataSource;
import net.xoetrope.xui.XProject;
import net.xoetrope.xui.XProjectManager;
import net.xoetrope.xui.XStartupObject;
import org.hsqldb.Server;

public class Main
{
  public static void main( String[] args )
  {
    try {
      // create and configure the NamedConnectionManager instance
      XProject project = XProjectManager.getCurrentProject( (XStartupObject)null );
      XOptionalDataSource dataSource = new XOptionalDataSource( project );
      dataSource.read( project.getBufferedReader( "datasets.xml", null ));

      // start the Hsqldb server (using the datastore at the "database/db" file path).
      args = new String[2];
      args[0] = "-database.0";
      args[1] = "file:database/db";     
      Server.main( args );
    }
    catch (Exception ex) {
      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
}

There are no comments on this page. [Add comment]

Page was generated in 0.2373 seconds