<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<section id="Core.DBSchemacreatorserviceJDBCimplementation">
  <title>DB Schema creator service (JDBC implementation)</title>

  <para>DB Schema Creator is responsible for creating database schema, using a
  DDL script inside service configuration or in an external file,
  calling:</para>

  <programlisting language="java">  org.exoplatform.services.database.jdbc.DBSchemaCreator.createTables(String dsName, String script)</programlisting>

  <para>via</para>

  <programlisting>org.exoplatform.services.database.jdbc.CreateDBSchemaPlugin component plugin</programlisting>

  <para>A configuration example:</para>

  <programlisting language="xml">&lt;component&gt;
   &lt;key&gt;org.exoplatform.services.database.jdbc.DBSchemaCreator&lt;/key&gt;
   &lt;type&gt;org.exoplatform.services.database.jdbc.DBSchemaCreator&lt;/type&gt;
   &lt;component-plugins&gt;    
      &lt;component-plugin&gt; 
         &lt;name&gt;jcr.dbschema&lt;/name&gt;
         &lt;set-method&gt;addPlugin&lt;/set-method&gt;
         &lt;type&gt;org.exoplatform.services.database.jdbc.CreateDBSchemaPlugin&lt;/type&gt;
         &lt;init-params&gt;
            &lt;value-param&gt;
               &lt;name&gt;data-source&lt;/name&gt;
               &lt;value&gt;jdbcjcr&lt;/value&gt;
            &lt;/value-param&gt;
            &lt;value-param&gt;
               &lt;name&gt;script-file&lt;/name&gt;
               &lt;value&gt;conf/storage/jcr-mjdbc.sql&lt;/value&gt;
            &lt;/value-param&gt;  
         &lt;/init-params&gt;    
      &lt;/component-plugin&gt;
  ........</programlisting>

  <para>An example of a DDL script:</para>

  <programlisting>CREATE TABLE JCR_MITEM(
        ID VARCHAR(255) NOT NULL PRIMARY KEY, 
        VERSION INTEGER NOT NULL, 
        PATH VARCHAR(1024) NOT NULL
        );
CREATE INDEX JCR_IDX_MITEM_PATH ON JCR_MITEM(PATH);</programlisting>
</section>
