Hi Christian and thank you for the help,

Ok for adding features at boot, I understand.

About "Then you also need to put a DataSource config in etc.", how can I
add this configuration?
Should I create a new file or do I need to edit an existing file in the
distribution?

my Karaf etc folder does not contains any file with jdbc (or pax-jdbc) in
its name, neither after installing the feature...
Thank you!

Cristiano




Il giorno mer 5 apr 2017 alle ore 11:54 Christian Schneider <
ch...@die-schneider.net> ha scritto:

> Yes you can create a DataSource that is available on first boot.
>
> To make this work you need to add the pax-jdbc features that are needed
> for your DataSource to the boot features.
> In your example that should be: pax-jdbc-config pax-jdbc-pool-dbcp2
> pax-jdbc-h2 transaction
> Then you also need to put a DataSource config in etc.
>
> If you then start karaf the DataSource service should come up.
>
> Christian
>
>
> On 05.04.2017 11:43, Cristiano Costantini wrote:
>
> hello,
>
> Is it possible to specify at configuration a JDBC datasource to be created
> when Karaf boots the first time?
>
> For information, I'm learning using Karaf JDBC (
> https://karaf.apache.org/manual/latest/#_datasources_jdbc) and then Karaf
> JPA (https://karaf.apache.org/manual/latest/#_persistence_jpa) to replace
> our current implementation which is based on Spring (spring-orm and
> spring-jdbc)
>
> I'm following the examples of Christian from
> https://github.com/apache/aries/tree/trunk/jpa/examples/
>
> where I've found the example command
> jdbc:ds-create -dn H2-pool-xa -url jdbc:h2:mem:tasklist tasklist
>
> that creates a data source and publish to OSGi registry its service:
> karaf@root>jdbc:ds-info tasklist
> Property       | Value
> -------------------------------------
> driver.version | 1.3.172 (2013-05-25)
> db.version     | 1.3.172 (2013-05-25)
> db.product     | H2
> url            | jdbc:h2:mem:tasklist
> driver.name    | H2 JDBC Driver
> username       |
>
> karaf@root>service:list javax.sql.DataSource
> [javax.sql.DataSource]
> ----------------------
>  dataSourceName = tasklist
>  osgi.jdbc.driver.name = H2-pool-xa
>  osgi.jndi.service.name = tasklist
>  service.bundleid = 222
>  service.factoryPid = org.ops4j.datasource
>  service.id = 403
>  service.pid = org.ops4j.datasource.ac08f704-67e1-40c8-8855-9e3e262f8a9e
>  service.scope = singleton
>  url = jdbc:h2:mem:tasklist
> Provided by :
>  OPS4J Pax JDBC Config (222)
> Used by:
>  Apache Karaf :: JDBC :: Core (226)
>
>
> Thank you !
> Cristiano
>
>
>
>
> --
> Christian Schneiderhttp://www.liquid-reality.de
>
> Open Source Architecthttp://www.talend.com
>
>

Reply via email to