Hi All,

You can easily create an H2 database form a given sql Script in your
project. I've attached a sample pom.xml.

This can be used in products as well as components repos. You can easily
populate an H2 database from an sql file for your component level OSGi
testing as well.

Thanks,
Sameera.

On Fri, Feb 12, 2016 at 4:32 PM, Akalanka Pagoda Arachchi <
darsha...@wso2.com> wrote:

> What I meant was, I already tried upgrading the H2 version to the latest
> version. When I did, the previous database URL's we were using failed since
> the new H2 driver is not taking relative paths for the URL.
>
> Thanks,
> Akalanka.
>
> On Fri, Feb 12, 2016 at 3:48 PM, Akalanka Pagoda Arachchi <
> darsha...@wso2.com> wrote:
>
>> We can, but we will have to verify all the database URL's again, since
>> when I tried, it gave me an exception since it was no longer accepting
>> relative paths.
>>
>> On Fri, Feb 12, 2016 at 3:46 PM, Ramith Jayasinghe <ram...@wso2.com>
>> wrote:
>>
>>> and shall we upgrade H2 version to latest?
>>>
>>> On Fri, Feb 12, 2016 at 2:24 PM, Ramith Jayasinghe <ram...@wso2.com>
>>> wrote:
>>> > So whats the verdict?
>>> > @sameera: can we have some thing similar to 'carbon-persistence' or
>>> > something which contains H2?
>>> >
>>> > On Fri, Feb 12, 2016 at 11:48 AM, Niranjan Karunanandham
>>> > <niran...@wso2.com> wrote:
>>> >> Hi Akalanka,
>>> >>
>>> >> On Fri, Feb 12, 2016 at 11:37 AM, Akalanka Pagoda Arachchi
>>> >> <darsha...@wso2.com> wrote:
>>> >>>
>>> >>> Hi Niranjan,
>>> >>>
>>> >>> Yes, we could have avoided adding h2-database-engine as a dependency
>>> in
>>> >>> 4.4.x Andes.
>>> >>>
>>> >>> If we add the h2 driver to the datasource feature, it would mean
>>> whenever
>>> >>> datasource feature is used h2 driver will be copied. Will that be
>>> OK? My
>>> >>> opinion is if the H2 driver is not a dependency for the feature, it
>>> should
>>> >>> not be contained in the feature. When we create a distribution from
>>> that
>>> >>> feature, if H2 DB is used as the default DB configuration, we should
>>> provide
>>> >>> the H2 driver with the distribution.
>>> >>
>>> >> Sorry about it. I was under the impression that the datasource core
>>> for C5
>>> >> supports by default is for H2 DB like in C4. This is why I suggested
>>> that we
>>> >> define it at the datasource core feature.
>>> >>
>>> >>>
>>> >>> WDYT?
>>> >>>
>>> >>> Thanks,
>>> >>> Akalanka.
>>> >>>
>>> >>> On Fri, Feb 12, 2016 at 11:05 AM, Niranjan Karunanandham
>>> >>> <niran...@wso2.com> wrote:
>>> >>>>
>>> >>>> Hi Akalanka / all
>>> >>>>
>>> >>>> On Fri, Feb 12, 2016 at 10:46 AM, Akalanka Pagoda Arachchi
>>> >>>> <darsha...@wso2.com> wrote:
>>> >>>>>
>>> >>>>> Hi All,
>>> >>>>>
>>> >>>>> In the previous distributions, we had H2 database driver as a
>>> dependency
>>> >>>>> for our features so that it will be copied to the plugins folder
>>> when the
>>> >>>>> pack is created.However, in this scenario, H2 database driver is
>>> not exactly
>>> >>>>> a dependency of the Andes Core feature since it is not using the
>>> H2 driver.
>>> >>>>
>>> >>>> Are you referring to the h2-database-engine jar? This was there in
>>> the
>>> >>>> plugins folder of kernel core zip in 4.4.x. If so, then why is
>>> andes core
>>> >>>> feature also packing this?
>>> >>>>
>>> >>>>>
>>> >>>>> Therefore, my suggestion is to avoid adding H2 database driver as a
>>> >>>>> dependency for the Andes Core feature, but rather add it as a
>>> dependency for
>>> >>>>> product distribution module so that when the distribution pack is
>>> created,
>>> >>>>> the H2 driver, which is required for default database
>>> configurations is
>>> >>>>> copied to the plugins folder.
>>> >>>>>
>>> >>>>> This will be useful in reducing the Andes Core feature bundle size
>>> as
>>> >>>>> well.
>>> >>>>>
>>> >>>>> If any product is to install Andes Core feature, they will have to
>>> copy
>>> >>>>> the relevant jar file to the dropins folder if they don't already
>>> have it.
>>> >>>>>
>>> >>>>> WDYT?
>>> >>>>>
>>> >>>>> If we're to go ahead with this approach we need a way to install
>>> osgi
>>> >>>>> bundles to the distribution that are not available in the features
>>> or create
>>> >>>>> a new feature containing H2 database driver.
>>> >>>>
>>> >>>> If we require a default DB, then I would suggest to have it with
>>> database
>>> >>>> core feature. WDYT?
>>> >>>>
>>> >>>>>
>>> >>>>>
>>> >>>>> Please provide your thoughts.
>>> >>>>>
>>> >>>>> Thanks,
>>> >>>>> Akalanka.
>>> >>>>>
>>> >>>>> --
>>> >>>>> Darshana Akalanka Pagoda Arachchi,
>>> >>>>> Software Engineer
>>> >>>>> 078-4721791
>>> >>>>
>>> >>>>
>>> >>>> Regards,
>>> >>>> Nira
>>> >>>>
>>> >>>> --
>>> >>>>
>>> >>>> Niranjan Karunanandham
>>> >>>> Senior Software Engineer - WSO2 Inc.
>>> >>>> WSO2 Inc.: http://www.wso2.com
>>> >>>
>>> >>>
>>> >>>
>>> >>>
>>> >>> --
>>> >>> Darshana Akalanka Pagoda Arachchi,
>>> >>> Software Engineer
>>> >>> 078-4721791
>>> >>
>>> >>
>>> >> Regards,
>>> >> Nira
>>> >>
>>> >> --
>>> >>
>>> >> Niranjan Karunanandham
>>> >> Senior Software Engineer - WSO2 Inc.
>>> >> WSO2 Inc.: http://www.wso2.com
>>> >
>>> >
>>> >
>>> > --
>>> > Ramith Jayasinghe
>>> > Technical Lead
>>> > WSO2 Inc., http://wso2.com
>>> > lean.enterprise.middleware
>>> >
>>> > E: ram...@wso2.com
>>> > P: +94 777542851
>>>
>>>
>>>
>>> --
>>> Ramith Jayasinghe
>>> Technical Lead
>>> WSO2 Inc., http://wso2.com
>>> lean.enterprise.middleware
>>>
>>> E: ram...@wso2.com
>>> P: +94 777542851
>>>
>>
>>
>>
>> --
>> *Darshana Akalanka Pagoda Arachchi,*
>> *Software Engineer*
>> *078-4721791*
>>
>
>
>
> --
> *Darshana Akalanka Pagoda Arachchi,*
> *Software Engineer*
> *078-4721791*
>



-- 
Sameera Jayasoma,
Software Architect,

WSO2, Inc. (http://wso2.com)
email: same...@wso2.com
blog: http://blog.sameera.org
twitter: https://twitter.com/sameerajayasoma
flickr: http://www.flickr.com/photos/sameera-jayasoma/collections
Mobile: 0094776364456

Lean . Enterprise . Middleware
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (c) 2016, WSO2 Inc. (http://wso2.com) All Rights Reserved.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns="http://maven.apache.org/POM/4.0.0";
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>

    <parent>
        <groupId>org.wso2</groupId>
        <artifactId>wso2</artifactId>
        <version>2</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>h2-database</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>H2 Database</name>
    <description>Create an H2 database from a given sql file.</description>
    <url>http://wso2.org</url>

    <dependencies>
        <dependency>
            <groupId>com.h2database.wso2</groupId>
            <artifactId>h2-database-engine</artifactId>
            <version>1.2.140.wso2v3</version>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.osgi</groupId>
                    <artifactId>org.eclipse.osgi</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>1-run-ant</id>
                        <phase>test</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
                                <path id="h2.classpath">
                                    <path refid="maven.compile.classpath" />
                                </path>
                                <echo message="########### Create Default Database ##############" />
                                <sql driver="org.h2.Driver" url="jdbc:h2:${basedir}/target/database/WSO2CARBON_DB" userid="wso2carbon" password="wso2carbon" autocommit="true" onerror="continue">
                                    <classpath>
                                        <path refid="h2.classpath" />
                                    </classpath>
                                    <fileset file="${basedir}/h2.sql" />
                                </sql>
                                <echo message="##################### END ########################" />
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
_______________________________________________
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to