You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2014/01/18 11:00:34 UTC

[1/2] [KARAF-2642] Merge jdbc feature

Updated Branches:
  refs/heads/karaf-2.x b53a09fc5 -> 36761d5d5


http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-hsql.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-hsql.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-hsql.xml
new file mode 100644
index 0000000..28fa3ea
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-hsql.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="dataSource" class="org.hsqldb.jdbc.JDBCDataSource">
+        <property name="URL" value="${url}"/>
+        <property name="user" value="${user}"/>
+        <property name="password" value="${password}"/>
+    </bean>
+
+    <service interface="javax.sql.DataSource" ref="dataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mysql.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mysql.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mysql.xml
new file mode 100644
index 0000000..3768cb6
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mysql.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
+        <property name="url" value="${url}"/>
+        <property name="user" value="${user}"/>
+        <property name="password" value="${test}"/>
+    </bean>
+
+    <service interface="javax.sql.DataSource" ref="dataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-oracle.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-oracle.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-oracle.xml
new file mode 100644
index 0000000..f9305de
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-oracle.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource">
+        <property name="URL" value="${url}"/>
+        <property name="user" value="${user}"/>
+        <property name="password" value="${password}"/>
+    </bean>
+
+    <service interface="javax.sql.DataSource" ref="dataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-postgres.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-postgres.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-postgres.xml
new file mode 100644
index 0000000..8599210
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-postgres.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="dataSource" class="org.postgresql.ds.PGPoolingDataSource" destroy-method="close">
+        <property name="serverName" value="${url}"/>
+        <property name="user" value="${user}"/>
+        <property name="password" value="${password}"/>
+        <property name="dataSourceName" value="${name}"/>
+        <property name="initialConnections" value="2"/>
+        <property name="maxConnections" value="4" />
+    </bean>
+
+    <service interface="javax.sql.DataSource" ref="dataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
new file mode 100644
index 0000000..e49a03e
--- /dev/null
+++ b/jdbc/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf</groupId>
+        <artifactId>karaf</artifactId>
+        <version>2.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <groupId>org.apache.karaf.jdbc</groupId>
+    <artifactId>jdbc</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Karaf :: JDBC</name>
+
+    <modules>
+        <module>core</module>
+        <module>command</module>
+    </modules>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index d207b35..8876807 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,6 +46,7 @@
         <module>client</module>
         <module>management</module>
         <module>jndi</module>
+        <module>jdbc</module>
         <module>webconsole</module>
         <module>exception</module>
         <module>assemblies</module>
@@ -472,6 +473,16 @@
                 <version>${project.version}</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.karaf.jdbc</groupId>
+                <artifactId>org.apache.karaf.jdbc.core</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.karaf.jdbc</groupId>
+                <artifactId>org.apache.karaf.jdbc.command</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>org.apache.karaf.webconsole</groupId>
                 <artifactId>org.apache.karaf.webconsole.admin</artifactId>
                 <version>${project.version}</version>


[2/2] git commit: [KARAF-2642] Merge jdbc feature

Posted by jb...@apache.org.
[KARAF-2642] Merge jdbc feature


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/36761d5d
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/36761d5d
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/36761d5d

Branch: refs/heads/karaf-2.x
Commit: 36761d5d5aed05c839cd8e41763a196160dde5f5
Parents: b53a09f
Author: Jean-Baptiste Onofré <jb...@apache.org>
Authored: Sat Jan 18 10:59:39 2014 +0100
Committer: Jean-Baptiste Onofré <jb...@apache.org>
Committed: Sat Jan 18 10:59:39 2014 +0100

----------------------------------------------------------------------
 .../enterprise/src/main/resources/features.xml  |   9 +
 jdbc/command/NOTICE                             |  71 +++++
 jdbc/command/pom.xml                            |  97 ++++++
 .../karaf/jdbc/command/CreateCommand.java       |  55 ++++
 .../karaf/jdbc/command/DataSourcesCommand.java  |  42 +++
 .../karaf/jdbc/command/DeleteCommand.java       |  33 ++
 .../karaf/jdbc/command/ExecuteCommand.java      |  36 +++
 .../apache/karaf/jdbc/command/InfoCommand.java  |  44 +++
 .../karaf/jdbc/command/JdbcCommandSupport.java  |  36 +++
 .../apache/karaf/jdbc/command/QueryCommand.java |  55 ++++
 .../karaf/jdbc/command/TablesCommand.java       |  56 ++++
 .../DataSourcesFileNameCompleter.java           |  52 +++
 .../completers/DataSourcesNameCompleter.java    |  52 +++
 .../OSGI-INF/blueprint/jdbc-command.xml         |  87 +++++
 .../src/main/resources/OSGI-INF/bundle.info     |  26 ++
 jdbc/core/NOTICE                                |  71 +++++
 jdbc/core/pom.xml                               |  88 ++++++
 .../java/org/apache/karaf/jdbc/JdbcMBean.java   |  96 ++++++
 .../java/org/apache/karaf/jdbc/JdbcService.java |  95 ++++++
 .../karaf/jdbc/internal/JdbcMBeanImpl.java      | 167 ++++++++++
 .../karaf/jdbc/internal/JdbcServiceImpl.java    | 316 +++++++++++++++++++
 .../resources/OSGI-INF/blueprint/jdbc-core.xml  |  43 +++
 .../src/main/resources/OSGI-INF/bundle.info     |  18 ++
 .../karaf/jdbc/internal/datasource-db2.xml      |  16 +
 .../karaf/jdbc/internal/datasource-derby.xml    |  23 ++
 .../karaf/jdbc/internal/datasource-generic.xml  | 125 ++++++++
 .../karaf/jdbc/internal/datasource-h2.xml       |  15 +
 .../karaf/jdbc/internal/datasource-hsql.xml     |  15 +
 .../karaf/jdbc/internal/datasource-mysql.xml    |  15 +
 .../karaf/jdbc/internal/datasource-oracle.xml   |  15 +
 .../karaf/jdbc/internal/datasource-postgres.xml |  18 ++
 jdbc/pom.xml                                    |  41 +++
 pom.xml                                         |  11 +
 33 files changed, 1939 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/assemblies/features/enterprise/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/enterprise/src/main/resources/features.xml b/assemblies/features/enterprise/src/main/resources/features.xml
index 8385337..fc6d7ee 100644
--- a/assemblies/features/enterprise/src/main/resources/features.xml
+++ b/assemblies/features/enterprise/src/main/resources/features.xml
@@ -157,6 +157,15 @@
         <bundle>mvn:org.apache.karaf.jndi/org.apache.karaf.jndi.command/${project.version}</bundle>
     </feature>
 
+    <feature name="jdbc" description="JDBC service and commands" version="${project.version}" resolver="(obr)">
+        <details>JDBC support providing service, commands, and MBean</details>
+        <feature>transaction</feature>
+        <bundle>mvn:commons-pool/commons-pool/${commons-pool.version}</bundle>
+        <bundle>mvn:commons-dbcp/commons-dbcp/${commons-dbcp.version}</bundle>
+        <bundle>mvn:org.apache.karaf.jdbc/org.apache.karaf.jdbc.core/${project.version}</bundle>
+        <bundle>mvn:org.apache.karaf.jdbc/org.apache.karaf.jdbc.command/${project.version}</bundle>
+    </feature>
+
     <feature name="openwebbeans" description="Apache OpenWebBeans CDI container support" version="${openwebbeans.version}" resolver="(obr)">
         <details>Add support of Apache OpenWebBeans CDI container.</details>
         <feature>http</feature>

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/NOTICE
----------------------------------------------------------------------
diff --git a/jdbc/command/NOTICE b/jdbc/command/NOTICE
new file mode 100644
index 0000000..de8d101
--- /dev/null
+++ b/jdbc/command/NOTICE
@@ -0,0 +1,71 @@
+Apache Karaf
+Copyright 2010-2013 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+OW2 (http://www.ow2.org/).
+Licensed under the BSD License.
+
+This product includes software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+Eclipse Foundation (http://www.eclipse.org/).
+Licensed under the EPL.
+
+This product includes software written by
+Antony Lesuisse.
+Licensed under Public Domain.
+
+
+II. Used Software
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+AOP Alliance (http://aopalliance.sourceforge.net/).
+Licensed under the Public Domain.
+
+This product uses software developed at
+Tanuki Software (http://www.tanukisoftware.com/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+Jasypt (http://jasypt.sourceforge.net/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JLine (http://jline.sourceforge.net).
+Licensed under the BSD License.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product uses software developed at
+SpringSource (http://www.springsource.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+
+III. License Summary
+- Apache License 2.0
+- BSD License
+- EPL License
+- MIT License

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/command/pom.xml b/jdbc/command/pom.xml
new file mode 100644
index 0000000..e77fed1
--- /dev/null
+++ b/jdbc/command/pom.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.jdbc</groupId>
+        <artifactId>jdbc</artifactId>
+        <version>2.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.karaf.jdbc.command</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Karaf :: JDBC :: Command</name>
+    <description>This bundle provides shell commands to manipulate the JDBC service</description>
+
+    <properties>
+        <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.karaf.jdbc</groupId>
+            <artifactId>org.apache.karaf.jdbc.core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.gogo.runtime</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*.info</include>
+                </includes>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Import-Package>
+                            org.apache.felix.service.command,
+                            org.apache.felix.gogo.commands,
+                            org.apache.karaf.shell.console,
+                            *
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java
new file mode 100644
index 0000000..dddb16b
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/CreateCommand.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+
+@Command(scope = "jdbc", name = "create", description = "Create a JDBC datasource")
+public class CreateCommand extends JdbcCommandSupport {
+
+    @Argument(index = 0, name = "name", description = "The JDBC datasource name", required = true, multiValued = false)
+    String name;
+
+    @Option(name = "-t", aliases = { "--type" }, description = "The JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby)", required = false, multiValued = false)
+    String type;
+
+    @Option(name = "-d", aliases = { "--driver" }, description = "The classname of the JDBC driver to use. NB: this option is used only the type generic", required = false, multiValued = false)
+    String driver;
+
+    @Option(name = "-v", aliases = { "--version" }, description = "The version of the driver to use", required = false, multiValued = false)
+    String version;
+
+    @Option(name = "-url", description = "The JDBC URL to use", required = false, multiValued = false)
+    String url;
+
+    @Option(name = "-u", aliases = { "--username" }, description = "The database username", required = false, multiValued = false)
+    String username;
+
+    @Option(name = "-p", aliases = { "--password" }, description = "The database password", required = false, multiValued = false)
+    String password;
+
+    @Option(name = "-i", aliases = { "--install-bundles" }, description = "Try to install the bundles providing the JDBC driver", required = false, multiValued = false)
+    boolean installBundles = false;
+
+    public Object doExecute() throws Exception {
+        this.getJdbcService().create(name, type, driver, version, url, username, password, installBundles);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java
new file mode 100644
index 0000000..67085b5
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DataSourcesCommand.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+import java.util.Map;
+
+@Command(scope = "jdbc", name = "datasources", description = "List the JDBC datasources")
+public class DataSourcesCommand extends JdbcCommandSupport {
+
+    private final static String JDBC_DATASOURCES_STRING_FORMAT = "%10s %15s %10s %45s";
+
+    public Object doExecute() throws Exception {
+
+        System.out.println(String.format(JDBC_DATASOURCES_STRING_FORMAT, "Name", "Product", "Version", "URL"));
+
+        List<String> datasources = this.getJdbcService().datasources();
+        for (String datasource : datasources) {
+            Map<String, String> info = this.getJdbcService().info(datasource);
+            System.out.println(String.format(JDBC_DATASOURCES_STRING_FORMAT, datasource, info.get("db.product"), info.get("db.version"), info.get("url")));
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java
new file mode 100644
index 0000000..e114d10
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/DeleteCommand.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "jdbc", name = "delete", description = "Delete a JDBC datasource")
+public class DeleteCommand extends JdbcCommandSupport {
+
+    @Argument(index = 0, name = "name", description = "The JDBC datasource name (the one used at creation time)", required = true, multiValued = false)
+    String name;
+
+    public Object doExecute() throws Exception {
+        this.getJdbcService().delete(name);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/ExecuteCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/ExecuteCommand.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/ExecuteCommand.java
new file mode 100644
index 0000000..8352842
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/ExecuteCommand.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "jdbc", name = "execute", description = "Execute a SQL command on a given JDBC datasource")
+public class ExecuteCommand extends JdbcCommandSupport {
+
+    @Argument(index = 0, name = "datasource", description = "The JDBC datasource", required = true, multiValued = false)
+    String datasource;
+
+    @Argument(index = 1, name = "command", description = "The SQL command to execute", required = true, multiValued = false)
+    String command;
+
+    public Object doExecute() throws Exception {
+        this.getJdbcService().execute(datasource, command);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java
new file mode 100644
index 0000000..ffe5f85
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/InfoCommand.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.Map;
+
+@Command(scope = "jdbc", name = "info", description = "Display details about a JDBC datasource")
+public class InfoCommand extends JdbcCommandSupport {
+
+    private final static String PROPERTIES_STRING_FORMAT = "%20s %20s";
+
+    @Argument(index = 0, name = "datasource", description = "The JDBC datasource name", required = true, multiValued = false)
+    String datasource;
+
+    public Object doExecute() throws Exception {
+
+        System.out.println(String.format(PROPERTIES_STRING_FORMAT, "Property", "Value"));
+
+        Map<String, String> info = this.getJdbcService().info(datasource);
+        for (String property : info.keySet()) {
+            System.out.println(String.format(PROPERTIES_STRING_FORMAT, property, info.get(property)));
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/JdbcCommandSupport.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/JdbcCommandSupport.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/JdbcCommandSupport.java
new file mode 100644
index 0000000..6fb8bfc
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/JdbcCommandSupport.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.karaf.jdbc.JdbcService;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+
+public abstract class JdbcCommandSupport extends OsgiCommandSupport {
+
+    private JdbcService jdbcService;
+
+    public abstract Object doExecute() throws Exception;
+
+    public JdbcService getJdbcService() {
+        return jdbcService;
+    }
+
+    public void setJdbcService(JdbcService jdbcService) {
+        this.jdbcService = jdbcService;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/QueryCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/QueryCommand.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/QueryCommand.java
new file mode 100644
index 0000000..3e32ca9
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/QueryCommand.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+import java.util.Map;
+
+@Command(scope = "jdbc", name = "query", description = "Execute a SQL query on a JDBC datasource")
+public class QueryCommand extends JdbcCommandSupport {
+
+    @Argument(index = 0, name = "datasource", description = "The JDBC datasource to use", required = true, multiValued = false)
+    String datasource;
+
+    @Argument(index = 1, name = "query", description = "The SQL query to execute", required = true, multiValued = false)
+    String query;
+
+    public Object doExecute() throws Exception {
+
+        Map<String, List<String>> map = this.getJdbcService().query(datasource, query);
+        int rowCount = 0;
+        for (String column : map.keySet()) {
+            System.out.print(column + "\t");
+            rowCount = map.get(column).size();
+        }
+
+        System.out.println("");
+
+        for (int i = 0; i < rowCount; i++) {
+            for (String column : map.keySet()) {
+                System.out.print(map.get(column).get(i) + "\t");
+            }
+            System.out.println("");
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/TablesCommand.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/TablesCommand.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/TablesCommand.java
new file mode 100644
index 0000000..4778aeb
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/TablesCommand.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+import java.util.Map;
+
+@Command(scope = "jdbc", name = "tables", description = "List the tables on a given JDBC datasource")
+public class TablesCommand extends JdbcCommandSupport {
+
+    @Argument(index = 0, name = "datasource", description = "The JDBC datasource to use", required = true, multiValued = false)
+    String datasource;
+
+    public Object doExecute() throws Exception {
+
+        Map<String, List<String>> map = this.getJdbcService().tables(datasource);
+        int rowCount = 0;
+        for (String column : map.keySet()) {
+            System.out.print(column + "\t");
+            rowCount = map.get(column).size();
+        }
+
+        System.out.println("");
+
+        for (int i = 0; i < rowCount; i++) {
+            for (String column : map.keySet()) {
+                if (map.get(column).get(i) == null) {
+                    System.out.print(" ");
+                } else {
+                    System.out.print(map.get(column).get(i));
+                }
+            }
+            System.out.println("");
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java
new file mode 100644
index 0000000..9733f86
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesFileNameCompleter.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command.completers;
+
+import org.apache.karaf.jdbc.JdbcService;
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+
+import java.util.List;
+
+/**
+ * Completer on the JDBC datasources file name.
+ */
+public class DataSourcesFileNameCompleter implements Completer {
+
+    private JdbcService jdbcService;
+
+    public int complete(String buffer, int cursor, List<String> candidates) {
+        StringsCompleter delegate = new StringsCompleter();
+        try {
+            for (String datasourceFileName : jdbcService.datasourceFileNames()) {
+                delegate.getStrings().add(datasourceFileName.replace("datasource-", "").replace(".xml", ""));
+            }
+        } catch (Exception e) {
+            // nothing to do
+        }
+        return delegate.complete(buffer, cursor, candidates);
+    }
+
+    public JdbcService getJdbcService() {
+        return jdbcService;
+    }
+
+    public void setJdbcService(JdbcService jdbcService) {
+        this.jdbcService = jdbcService;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesNameCompleter.java
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesNameCompleter.java b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesNameCompleter.java
new file mode 100644
index 0000000..67e3635
--- /dev/null
+++ b/jdbc/command/src/main/java/org/apache/karaf/jdbc/command/completers/DataSourcesNameCompleter.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.command.completers;
+
+import org.apache.karaf.jdbc.JdbcService;
+import org.apache.karaf.shell.console.Completer;
+import org.apache.karaf.shell.console.completer.StringsCompleter;
+
+import java.util.List;
+
+/**
+ * Completer on the JDBC datasources name (JNDI or OSGi service property).
+ */
+public class DataSourcesNameCompleter implements Completer {
+
+    private JdbcService jdbcService;
+
+    public int complete(String buffer, int cursor, List<String> candidates) {
+        StringsCompleter delegate = new StringsCompleter();
+        try {
+            for (String datasource : jdbcService.datasources()) {
+                delegate.getStrings().add(datasource);
+            }
+        } catch (Exception e) {
+            // nothing to do
+        }
+        return delegate.complete(buffer, cursor, candidates);
+    }
+
+    public JdbcService getJdbcService() {
+        return jdbcService;
+    }
+
+    public void setJdbcService(JdbcService jdbcService) {
+        this.jdbcService = jdbcService;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/resources/OSGI-INF/blueprint/jdbc-command.xml
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/resources/OSGI-INF/blueprint/jdbc-command.xml b/jdbc/command/src/main/resources/OSGI-INF/blueprint/jdbc-command.xml
new file mode 100644
index 0000000..4c6cc00
--- /dev/null
+++ b/jdbc/command/src/main/resources/OSGI-INF/blueprint/jdbc-command.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements. See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
+
+    <reference id="jdbcService" interface="org.apache.karaf.jdbc.JdbcService" />
+
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
+        <command name="jdbc/create">
+            <action class="org.apache.karaf.jdbc.command.CreateCommand">
+                <property name="jdbcService" ref="jdbcService"/>
+            </action>
+        </command>
+        <command name="jdbc/delete">
+            <action class="org.apache.karaf.jdbc.command.DeleteCommand">
+                <property name="jdbcService" ref="jdbcService"/>
+            </action>
+            <completers>
+                <ref component-id="datasourcesFileNameCompleter"/>
+                <null/>
+            </completers>
+        </command>
+        <command name="jdbc/datasources">
+            <action class="org.apache.karaf.jdbc.command.DataSourcesCommand">
+                <property name="jdbcService" ref="jdbcService"/>
+            </action>
+        </command>
+        <command name="jdbc/query">
+            <action class="org.apache.karaf.jdbc.command.QueryCommand">
+                <property name="jdbcService" ref="jdbcService"/>
+            </action>
+            <completers>
+                <ref component-id="datasourcesNameCompleter"/>
+                <null/>
+            </completers>
+        </command>
+        <command name="jdbc/execute">
+            <action class="org.apache.karaf.jdbc.command.ExecuteCommand">
+                <property name="jdbcService" ref="jdbcService"/>
+            </action>
+            <completers>
+                <ref component-id="datasourcesNameCompleter"/>
+                <null/>
+            </completers>
+        </command>
+        <command name="jdbc/info">
+            <action class="org.apache.karaf.jdbc.command.InfoCommand">
+                <property name="jdbcService" ref="jdbcService"/>
+            </action>
+            <completers>
+                <ref component-id="datasourcesNameCompleter"/>
+                <null/>
+            </completers>
+        </command>
+        <command name="jdbc/tables">
+            <action class="org.apache.karaf.jdbc.command.TablesCommand">
+                <property name="jdbcService" ref="jdbcService"/>
+            </action>
+            <completers>
+                <ref component-id="datasourcesNameCompleter"/>
+                <null/>
+            </completers>
+        </command>
+    </command-bundle>
+
+    <bean id="datasourcesNameCompleter" class="org.apache.karaf.jdbc.command.completers.DataSourcesNameCompleter">
+        <property name="jdbcService" ref="jdbcService" />
+    </bean>
+    <bean id="datasourcesFileNameCompleter" class="org.apache.karaf.jdbc.command.completers.DataSourcesFileNameCompleter">
+        <property name="jdbcService" ref="jdbcService" />
+    </bean>
+
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/command/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/jdbc/command/src/main/resources/OSGI-INF/bundle.info b/jdbc/command/src/main/resources/OSGI-INF/bundle.info
new file mode 100644
index 0000000..f4d4790
--- /dev/null
+++ b/jdbc/command/src/main/resources/OSGI-INF/bundle.info
@@ -0,0 +1,26 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+This bundle provides the shell commands to manipulate the JDBC service.
+
+The following commands are available:
+
+* jdbc:create
+* jdbc:delete
+* jdbc:datasources
+* jdbc:command
+* jdbc:query
+* jdbc:tables
+* jdbc:info
+
+h1. See also
+
+JDBC - section of the Karaf User Guide
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/NOTICE
----------------------------------------------------------------------
diff --git a/jdbc/core/NOTICE b/jdbc/core/NOTICE
new file mode 100644
index 0000000..de8d101
--- /dev/null
+++ b/jdbc/core/NOTICE
@@ -0,0 +1,71 @@
+Apache Karaf
+Copyright 2010-2013 The Apache Software Foundation
+
+
+I. Included Software
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2010).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+OW2 (http://www.ow2.org/).
+Licensed under the BSD License.
+
+This product includes software developed at
+OPS4J (http://www.ops4j.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+Eclipse Foundation (http://www.eclipse.org/).
+Licensed under the EPL.
+
+This product includes software written by
+Antony Lesuisse.
+Licensed under Public Domain.
+
+
+II. Used Software
+
+This product uses software developed at
+FUSE Source (http://www.fusesource.org/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+AOP Alliance (http://aopalliance.sourceforge.net/).
+Licensed under the Public Domain.
+
+This product uses software developed at
+Tanuki Software (http://www.tanukisoftware.com/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+Jasypt (http://jasypt.sourceforge.net/).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+JLine (http://jline.sourceforge.net).
+Licensed under the BSD License.
+
+This product uses software developed at
+SLF4J (http://www.slf4j.org/).
+Licensed under the MIT License.
+
+This product uses software developed at
+SpringSource (http://www.springsource.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software from http://www.json.org.
+Copyright (c) 2002 JSON.org
+
+
+III. License Summary
+- Apache License 2.0
+- BSD License
+- EPL License
+- MIT License

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/pom.xml b/jdbc/core/pom.xml
new file mode 100644
index 0000000..7deed87
--- /dev/null
+++ b/jdbc/core/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements.  See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.jdbc</groupId>
+        <artifactId>jdbc</artifactId>
+        <version>2.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.karaf.jdbc.core</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Karaf :: JDBC :: Core</name>
+    <description>This bundle provides core implementation of the JDBC service.</description>
+
+    <properties>
+        <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <resources>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>${project.basedir}/src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*.info</include>
+                </includes>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.apache.karaf.jdbc
+                        </Export-Package>
+                        <Import-Package>
+                            javax.management,
+                            javax.management.loading,
+                            org.apache.karaf.management;version=${project.version},
+                            *
+                        </Import-Package>
+                        <Private-Package>
+                            org.apache.karaf.jdbc.internal
+                        </Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java b/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
new file mode 100644
index 0000000..f899874
--- /dev/null
+++ b/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc;
+
+import javax.management.MBeanException;
+import javax.management.openmbean.TabularData;
+import java.util.Map;
+
+/**
+ * JDBC MBean
+ */
+public interface JdbcMBean {
+
+    /**
+     * Get the list of JDBC datasources.
+     *
+     * @return a tabular data containing the list of JDBC datasources.
+     * @throws MBeanException
+     */
+    TabularData getDatasources() throws MBeanException;
+
+    /**
+     * Create a JDBC datasource.
+     *
+     * @param name the JDBC datasource name.
+     * @param type the JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby).
+     * @param driver the JDBC datasource driver class name (can be null).
+     * @param version the target JDBC driver version (can be null).
+     * @param url the JDBC URL.
+     * @param user the database username.
+     * @param password the database password.
+     * @param installBundles true to install the bundles providing the JDBC driver, false to not install.
+     * @throws MBeanException
+     */
+    void create(String name, String type, String driver, String version, String url, String user, String password, boolean installBundles) throws MBeanException;
+
+    /**
+     * Delete a JDBC datasource.
+     *
+     * @param name the JDBC datasource name (the one used at creation time).
+     * @throws MBeanException
+     */
+    void delete(String name) throws MBeanException;
+
+    /**
+     * Get details about a JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @return a map (property/value) containing JDBC datasource details.
+     * @throws MBeanException
+     */
+    Map<String, String> info(String datasource) throws MBeanException;
+
+    /**
+     * Get the tables available on a JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @return a tabular data containg datasource tables.
+     * @throws MBeanException
+     */
+    TabularData tables(String datasource) throws MBeanException;
+
+    /**
+     * Execute a SQL command on a JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @param command the SQL command to execute.
+     * @throws MBeanException
+     */
+    void execute(String datasource, String command) throws MBeanException;
+
+    /**
+     * Execute a SQL query on a JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @param query the SQL query to execute.
+     * @return a tabular data with the result of execute (columns/values).
+     * @throws MBeanException
+     */
+    TabularData query(String datasource, String query) throws MBeanException;
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcService.java
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcService.java b/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcService.java
new file mode 100644
index 0000000..d883a07
--- /dev/null
+++ b/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcService.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * JDBC Service.
+ */
+public interface JdbcService {
+
+    /**
+     * Create a JDBC datasource (using a default template).
+     *
+     * @param name the JDBC datasource name.
+     * @param type the backend database type (generic, Oracle, MySQL, ...)
+     * @param driverClassName the JDBC driver classname.
+     * @param version the JDBC driver version to use.
+     * @param url the JDBC URL.
+     * @param user the database user name.
+     * @param password the database password.
+     * @param tryToInstallBundles true to try to automatically install the required bundles (JDBC driver, etc) when possible, false else.
+     */
+    void create(String name, String type, String driverClassName, String version, String url, String user, String password, boolean tryToInstallBundles) throws Exception;
+
+    /**
+     * Delete a JDBC datasource identified by a name.
+     *
+     * @param name the JDBC datasource name.
+     */
+    void delete(String name) throws Exception;
+
+    /**
+     * List the JDBC datasources available.
+     *
+     * @return a list of datasources name.
+     */
+    List<String> datasources() throws Exception;
+
+    /**
+     * List the JDBC datasources configuration file names present in the deploy folder.
+     *
+     * @return a list of the JDBC datasources configuration file names.
+     */
+    List<String> datasourceFileNames() throws Exception;
+
+    /**
+     * Execute a SQL query on a given JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @param query the SQL query to execute.
+     * @return the SQL query result (as a String).
+     */
+    Map<String, List<String>> query(String datasource, String query) throws Exception;
+
+    /**
+     * Execute a SQL command on a given JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @param command the SQL command to execute.
+     */
+    void execute(String datasource, String command) throws Exception;
+
+    /**
+     * List the tables available on a given JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @return the list of table names.
+     */
+    Map<String, List<String>> tables(String datasource) throws Exception;
+
+    /**
+     * Get detailed info about a JDBC datasource.
+     *
+     * @param datasource the JDBC datasource name.
+     * @return a map of info (name/value).
+     */
+    Map<String, String> info(String datasource) throws Exception;
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java b/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
new file mode 100644
index 0000000..e9d4dea
--- /dev/null
+++ b/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcMBeanImpl.java
@@ -0,0 +1,167 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.internal;
+
+import org.apache.karaf.jdbc.JdbcMBean;
+import org.apache.karaf.jdbc.JdbcService;
+
+import javax.management.MBeanException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+import javax.management.openmbean.*;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Default implementation of the JDBC MBean.
+ */
+public class JdbcMBeanImpl extends StandardMBean implements JdbcMBean {
+
+    private JdbcService jdbcService;
+
+    public JdbcMBeanImpl() throws NotCompliantMBeanException {
+        super(JdbcMBean.class);
+    }
+
+    public TabularData getDatasources() throws MBeanException {
+        try {
+            CompositeType type = new CompositeType("DataSource", "JDBC DataSource",
+                    new String[]{ "name", "product", "version", "url "},
+                    new String[]{ "Name", "Database product", "Database version", "JDBC URL" },
+                    new OpenType[]{ SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING });
+            TabularType tableType = new TabularType("JDBC DataSources", "Table of the JDBC DataSources",
+                    type, new String[]{ "name" });
+            TabularData table = new TabularDataSupport(tableType);
+
+            for (String datasource : jdbcService.datasources()) {
+                Map<String, String> info = jdbcService.info(datasource);
+                CompositeData data = new CompositeDataSupport(type,
+                        new String[]{ "name", "product", "version", "url" },
+                        new Object[]{ datasource, info.get("db.product"), info.get("db.version"), info.get("url") });
+                table.put(data);
+            }
+
+            return table;
+        } catch (Exception e) {
+            throw new MBeanException(null, e.getMessage());
+        }
+    }
+
+    public void create(String name, String type, String driver, String version, String url, String user, String password, boolean installBundles) throws MBeanException {
+        try {
+            jdbcService.create(name, type, driver, version, url, user, password, installBundles);
+        } catch (Exception e) {
+            throw new MBeanException(null, e.getMessage());
+        }
+    }
+
+    public void delete(String name) throws MBeanException {
+        try {
+            jdbcService.delete(name);
+        } catch (Exception e) {
+            throw new MBeanException(null, e.getMessage());
+        }
+    }
+
+    public Map<String, String> info(String datasource) throws MBeanException {
+        try {
+            return jdbcService.info(datasource);
+        } catch (Exception e) {
+            throw new MBeanException(null, e.getMessage());
+        }
+    }
+
+    public TabularData tables(String datasource) throws MBeanException {
+        try {
+            Map<String, List<String>> result = jdbcService.tables(datasource);
+            OpenType[] stringTypes = new OpenType[result.keySet().size()];
+            for (int i = 0; i < stringTypes.length; i++) {
+                stringTypes[i] = SimpleType.STRING;
+            }
+            String[] columns = result.keySet().toArray(new String[result.keySet().size()]);
+
+            CompositeType type = new CompositeType("Columns", "Columns",
+                    columns, columns, stringTypes);
+            TabularType rows = new TabularType("Result", "Result Rows", type, columns);
+            TabularData table = new TabularDataSupport(rows);
+
+            int rowCount = result.get(result.keySet().iterator().next()).size();
+
+            for (int i = 0; i < rowCount; i++) {
+                Object[] row = new Object[columns.length];
+                for (int j = 0; j < columns.length; j++) {
+                    row[j] = result.get(columns[j]).get(i);
+                }
+                CompositeData data = new CompositeDataSupport(type, columns, row);
+                table.put(data);
+            }
+
+            return table;
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new MBeanException(null, e.getMessage());
+        }
+    }
+
+    public void execute(String datasource, String command) throws MBeanException {
+        try {
+            jdbcService.execute(datasource, command);
+        } catch (Exception e) {
+            throw new MBeanException(null, e.getMessage());
+        }
+    }
+
+    public TabularData query(String datasource, String query) throws MBeanException {
+        try {
+            Map<String, List<String>> result = jdbcService.query(datasource, query);
+            OpenType[] stringTypes = new OpenType[result.keySet().size()];
+            for (int i = 0; i < stringTypes.length; i++) {
+                stringTypes[i] = SimpleType.STRING;
+            }
+            String[] columns = result.keySet().toArray(new String[result.keySet().size()]);
+
+            CompositeType type = new CompositeType("Columns", "Columns",
+                    columns, columns, stringTypes);
+            TabularType rows = new TabularType("Result", "Result Rows", type, columns);
+            TabularData table = new TabularDataSupport(rows);
+
+            int rowCount = result.get(result.keySet().iterator().next()).size();
+
+            for (int i = 0; i < rowCount; i++) {
+                Object[] row = new Object[columns.length];
+                for (int j = 0; j < columns.length; j++) {
+                    row[j] = result.get(columns[j]).get(i);
+                }
+                CompositeData data = new CompositeDataSupport(type, columns, row);
+                table.put(data);
+            }
+
+            return table;
+        } catch (Exception e) {
+            throw new MBeanException(null, e.getMessage());
+        }
+    }
+
+    public JdbcService getJdbcService() {
+        return jdbcService;
+    }
+
+    public void setJdbcService(JdbcService jdbcService) {
+        this.jdbcService = jdbcService;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java b/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
new file mode 100644
index 0000000..5cd41d5
--- /dev/null
+++ b/jdbc/core/src/main/java/org/apache/karaf/jdbc/internal/JdbcServiceImpl.java
@@ -0,0 +1,316 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.karaf.jdbc.internal;
+
+import org.apache.karaf.jdbc.JdbcService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+import javax.sql.DataSource;
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+
+/**
+ * Default implementation of the JDBC Service.
+ */
+public class JdbcServiceImpl implements JdbcService {
+
+    public static enum TYPES {
+        DB2("wrap:mvn:com.ibm.db2.jdbc/db2jcc/", "9.7", "datasource-db2.xml"),
+        DERBY("mvn:org.apache.derby/derby/", "10.8.2.2", "datasource-derby.xml"),
+        GENERIC(null, null, "datasource-generic.xml"),
+        H2("mvn:com.h2database/h2/", "1.3.163", "datasource-h2.xml"),
+        HSQL("mvn:com.h2database/h2/", "1.3.163", "datasource-hsql.xml"),
+        MYSQL("mvn:mysql/mysql-connector-java/", "5.1.18", "datasource-mysql.xml"),
+        ORACLE("wrap:mvn:ojdbc/ojdbc/", "11.2.0.2.0", "datasource-oracle.xml"),
+        POSTGRES("wrap:mvn:postgresql/postgresql/", "9.1-901.jdbc4", "datasource-postgres.xml");
+
+        private final String bundleUrl;
+        private final String defaultVersion;
+        private final String templateFile;
+
+        TYPES(String bundleUrl, String defaultVersion, String templateFile) {
+            this.bundleUrl = bundleUrl;
+            this.defaultVersion = defaultVersion;
+            this.templateFile = templateFile;
+        }
+
+        public void installBundle(BundleContext bundleContext, String version) throws Exception {
+            if (version != null) {
+                bundleContext.installBundle(this.bundleUrl + version, null).start();
+            } else {
+                bundleContext.installBundle(this.bundleUrl + this.defaultVersion, null).start();
+            }
+        }
+
+        public void copyDataSourceFile(File outFile, HashMap<String, String> properties) throws Exception {
+            if (!outFile.exists()) {
+                InputStream is = JdbcServiceImpl.class.getResourceAsStream(this.templateFile);
+                if (is == null) {
+                    throw new IllegalArgumentException("Resource " + this.templateFile + " doesn't exist");
+                }
+                try {
+                    // read it line at a time so that we can use the platform line ending when we write it out
+                    PrintStream out = new PrintStream(new FileOutputStream(outFile));
+                    try {
+                        Scanner scanner = new Scanner(is);
+                        while (scanner.hasNextLine()) {
+                            String line = scanner.nextLine();
+                            line = filter(line, properties);
+                            out.println(line);
+                        }
+                    } finally {
+                        safeClose(out);
+                    }
+                } finally {
+                    safeClose(is);
+                }
+            } else {
+                throw new IllegalArgumentException("File " + outFile.getPath() + " already exists. Remove it if you wish to recreate it.");
+            }
+        }
+
+        private void safeClose(InputStream is) throws IOException {
+            if (is == null)
+                return;
+            try {
+                is.close();
+            } catch (Throwable ignore) {
+                // nothing to do
+            }
+        }
+
+        private void safeClose(OutputStream is) throws IOException {
+            if (is == null)
+                return;
+            try {
+                is.close();
+            } catch (Throwable ignore) {
+                // nothing to do
+            }
+        }
+
+        private String filter(String line, HashMap<String, String> props) {
+            for (Map.Entry<String, String> i : props.entrySet()) {
+                int p1 = line.indexOf(i.getKey());
+                if (p1 >= 0) {
+                    String l1 = line.substring(0, p1);
+                    String l2 = line.substring(p1 + i.getKey().length());
+                    line = l1 + i.getValue() + l2;
+                }
+            }
+            return line;
+        }
+    }
+
+    private BundleContext bundleContext;
+
+    public void create(String name, String type, String driverClassName, String version, String url, String user, String password, boolean tryToInstallBundles) throws Exception {
+        if (tryToInstallBundles) {
+            TYPES.valueOf(type.toUpperCase()).installBundle(bundleContext, version);
+        }
+
+        File karafBase = new File(System.getProperty("karaf.base"));
+        File deployFolder = new File(karafBase, "deploy");
+        File outFile = new File(deployFolder, "datasource-" + name + ".xml");
+
+        HashMap<String, String> properties = new HashMap<String, String>();
+        properties.put("${name}", name);
+        properties.put("${driver}", driverClassName);
+        properties.put("${url}", url);
+        properties.put("${user}", user);
+        properties.put("${password}", password);
+
+        TYPES.valueOf(type.toUpperCase()).copyDataSourceFile(outFile, properties);
+    }
+
+    public void delete(String name) throws Exception {
+        File karafBase = new File(System.getProperty("karaf.base"));
+        File deployFolder = new File(karafBase, "deploy");
+        File datasourceFile = new File(deployFolder, "datasource-" + name + ".xml");
+        if (!datasourceFile.exists()) {
+            throw new IllegalArgumentException("The JDBC datasource file "+ datasourceFile.getPath() + " doesn't exist");
+        }
+        datasourceFile.delete();
+    }
+
+    public List<String> datasources() throws Exception {
+        List<String> datasources = new ArrayList<String>();
+        ServiceReference[] references = bundleContext.getServiceReferences(DataSource.class.getName(), null);
+        if (references != null) {
+            for (ServiceReference reference : references) {
+                if (reference.getProperty("osgi.jndi.service.name") != null) {
+                    datasources.add((String) reference.getProperty("osgi.jndi.service.name"));
+                } else if (reference.getProperty("datasource") != null) {
+                    datasources.add((String) reference.getProperty("datasource"));
+                } else if (reference.getProperty("name") != null) {
+                    datasources.add((String) reference.getProperty("name"));
+                } else {
+                    datasources.add(reference.getProperty(Constants.SERVICE_ID).toString());
+                }
+            }
+        }
+        return datasources;
+    }
+
+    public List<String> datasourceFileNames() throws Exception {
+        File karafBase = new File(System.getProperty("karaf.base"));
+        File deployFolder = new File(karafBase, "deploy");
+
+        String[] datasourceFileNames = deployFolder.list(new FilenameFilter() {
+
+            public boolean accept(File dir, String name) {
+                return name.startsWith("datasource-") && name.endsWith(".xml");
+            }
+        });
+
+        return Arrays.asList(datasourceFileNames);
+    }
+
+    public Map<String, List<String>> query(String datasource, String query) throws Exception {
+        Map<String, List<String>> map = new HashMap<String, List<String>>();
+        ServiceReference reference = this.lookupDataSource(datasource);
+        Connection connection = null;
+        Statement statement = null;
+        try {
+            DataSource ds = (DataSource) bundleContext.getService(reference);
+            connection = ds.getConnection();
+            statement = connection.createStatement();
+            ResultSet resultSet = statement.executeQuery(query);
+            ResultSetMetaData metaData = resultSet.getMetaData();
+            for (int c = 1; c <= metaData.getColumnCount(); c++) {
+                map.put(metaData.getColumnLabel(c), new ArrayList<String>());
+            }
+            while (resultSet.next()) {
+                for (int c = 1; c <= metaData.getColumnCount(); c++) {
+                    map.get(metaData.getColumnLabel(c)).add(resultSet.getString(c));
+                }
+            }
+            resultSet.close();
+        } finally {
+            if (statement != null) {
+                statement.close();
+            }
+            if (connection != null) {
+                connection.close();
+            }
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+        return map;
+    }
+
+    public void execute(String datasource, String command) throws Exception {
+        ServiceReference reference = this.lookupDataSource(datasource);
+        Connection connection = null;
+        Statement statement = null;
+        try {
+            DataSource ds = (DataSource) bundleContext.getService(reference);
+            connection = ds.getConnection();
+            statement = connection.createStatement();
+            statement.execute(command);
+        } finally {
+            if (statement != null) {
+                statement.close();
+            }
+            if (connection != null) {
+                connection.close();
+            }
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+    }
+
+    public Map<String, List<String>> tables(String datasource) throws Exception {
+        Map<String, List<String>> map = new HashMap<String, List<String>>();
+        ServiceReference reference = this.lookupDataSource(datasource);
+        Connection connection = null;
+        try {
+            DataSource ds = (DataSource) bundleContext.getService(reference);
+            connection = ds.getConnection();
+            DatabaseMetaData dbMetaData = connection.getMetaData();
+            ResultSet resultSet = dbMetaData.getTables(null, null, null, null);
+            ResultSetMetaData metaData = resultSet.getMetaData();
+            for (int c = 1; c <= metaData.getColumnCount(); c++) {
+                map.put(metaData.getColumnLabel(c), new ArrayList<String>());
+            }
+            while (resultSet.next()) {
+                for (int c = 1; c <= metaData.getColumnCount(); c++) {
+                    map.get(metaData.getColumnLabel(c)).add(resultSet.getString(c));
+                }
+            }
+            resultSet.close();
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+        return map;
+    }
+
+    public Map<String, String> info(String datasource) throws Exception {
+        Map<String, String> map = new HashMap<String, String>();
+        ServiceReference reference = this.lookupDataSource(datasource);
+        Connection connection = null;
+        try {
+            DataSource ds = (DataSource) bundleContext.getService(reference);
+            connection = ds.getConnection();
+            DatabaseMetaData dbMetaData = connection.getMetaData();
+            map.put("db.product", dbMetaData.getDatabaseProductName());
+            map.put("db.version", dbMetaData.getDatabaseProductVersion());
+            map.put("url", dbMetaData.getURL());
+            map.put("username", dbMetaData.getUserName());
+            map.put("driver.name", dbMetaData.getDriverName());
+            map.put("driver.version", dbMetaData.getDriverVersion());
+        } finally {
+            if (connection != null) {
+                connection.close();
+            }
+            if (reference != null) {
+                bundleContext.ungetService(reference);
+            }
+        }
+        return map;
+    }
+
+    private ServiceReference lookupDataSource(String name) throws Exception {
+        ServiceReference[] references = bundleContext.getServiceReferences(DataSource.class.getName(), "(|(osgi.jndi.service.name=" + name + ")(datasource=" + name + ")(name=" + name + ")(service.id=" + name + "))");
+        if (references == null || references.length == 0) {
+            throw new IllegalArgumentException("No JDBC datasource found for " + name);
+        }
+        if (references.length > 1) {
+            throw new IllegalArgumentException("Multiple JDBC datasource found for " + name);
+        }
+        return references[0];
+    }
+
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/OSGI-INF/blueprint/jdbc-core.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/OSGI-INF/blueprint/jdbc-core.xml b/jdbc/core/src/main/resources/OSGI-INF/blueprint/jdbc-core.xml
new file mode 100644
index 0000000..5f4fa3f
--- /dev/null
+++ b/jdbc/core/src/main/resources/OSGI-INF/blueprint/jdbc-core.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+        Licensed to the Apache Software Foundation (ASF) under one or more
+        contributor license agreements. See the NOTICE file distributed with
+        this work for additional information regarding copyright ownership.
+        The ASF licenses this file to You 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.
+    -->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="jdbcService" class="org.apache.karaf.jdbc.internal.JdbcServiceImpl">
+        <property name="bundleContext" ref="blueprintBundleContext"/>
+    </bean>
+
+    <service ref="jdbcService" interface="org.apache.karaf.jdbc.JdbcService" />
+
+    <!-- Management -->
+    <bean id="jdbcMBeanImpl" class="org.apache.karaf.jdbc.internal.JdbcMBeanImpl">
+        <property name="jdbcService" ref="jdbcService"/>
+    </bean>
+
+    <reference id="mbeanServer" interface="javax.management.MBeanServer">
+        <reference-listener ref="mbeanRegister" bind-method="registerMBeanServer" unbind-method="unregisterMBeanServer" />
+    </reference>
+
+    <bean id="mbeanRegister" class="org.apache.karaf.management.MBeanRegistrer" init-method="init"  destroy-method="destroy">
+        <property name="mbeans">
+            <map>
+                <entry value="org.apache.karaf:type=jdbc,name=${karaf.name}" key-ref="jdbcMBeanImpl" />
+            </map>
+        </property>
+    </bean>
+
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/OSGI-INF/bundle.info
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/OSGI-INF/bundle.info b/jdbc/core/src/main/resources/OSGI-INF/bundle.info
new file mode 100644
index 0000000..bc7a1cd
--- /dev/null
+++ b/jdbc/core/src/main/resources/OSGI-INF/bundle.info
@@ -0,0 +1,18 @@
+h1. Synopsis
+
+${project.name}
+
+${project.description}
+
+Maven URL:
+[mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+This bundle is the core implementation of the JDBC service support.
+
+The JDBC service allows you to create datasources, see the defined datasources, execute query on a datasource, etc.
+
+h1. See also
+
+JDBC - section of the Karaf User Guide

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-db2.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-db2.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-db2.xml
new file mode 100644
index 0000000..46128ab
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-db2.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="dataSource" class="com.ibm.db2.jcc.DB2DataSource">
+        <property name="url" value="${url}"/>
+        <property name="user" value="${user}"/>
+        <property name="password" value="${password}"/>
+    </bean>
+
+    <service interface="javax.sql.DataSource" ref="dataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-derby.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-derby.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-derby.xml
new file mode 100644
index 0000000..cd088dd
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-derby.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+           default-activation="eager">
+
+    <bean id="dataSource" class="org.apache.derby.jdbc.EmbeddedXADataSource">
+        <property name="databaseName" value="${name}"/>
+        <property name="createDatabase" value="create" />
+    </bean>
+
+    <service ref="dataSource" interface="javax.sql.DataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+
+    <service ref="dataSource" interface="javax.sql.XADataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}xa"/>
+        </service-properties>
+    </service>
+
+</blueprint>

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-generic.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-generic.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-generic.xml
new file mode 100644
index 0000000..d64405f
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-generic.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
+        <property name="driverClassName" value="${driver}"/>
+        <property name="url" value="${url}"/>
+        <property name="user" value="${user}"/>
+        <property name="password" value="${password}"/>
+        <property name="maxIdle" value="1"/>
+    </bean>
+
+    <bean id="connectionFactory" class="org.apache.commons.dbcp.DataSourceConnectionFactory">
+        <argument ref="dataSource" />
+    </bean>
+
+    <bean id="connectionPool" class="org.apache.commons.pool.impl.GenericObjectPool" >
+        <!-- No default factory -->
+        <argument><null/></argument> <!-- factory -->
+        <!--
+            controls the maximum number of objects that can be allocated by the pool (checked out to clients, or
+            idle awaiting checkout) at a given time. When non-positive, there is no limit to the number of objects that can
+            be managed by the pool at one time. When maxActive is reached, the pool is said to be exhausted.
+            The default setting for this parameter is 8.
+         -->
+        <argument value="8" /> <!-- maxActive -->
+        <!--
+            specifies the behavior of the borrowObject() method when the pool is exhausted:
+
+            When whenExhaustedAction is WHEN_EXHAUSTED_FAIL, borrowObject() will throw a NoSuchElementException
+            When whenExhaustedAction is WHEN_EXHAUSTED_GROW, borrowObject() will create a new object and return it
+            (essentially making maxActive meaningless.)
+            When whenExhaustedAction is WHEN_EXHAUSTED_BLOCK, borrowObject() will block (invoke Object.wait()) until
+            a new or idle object is available. If a positive maxWait value is supplied, then borrowObject() will block for at most that many milliseconds, after which a NoSuchElementException will be thrown. If maxWait is non-positive, the borrowObject() method will block indefinitely.
+
+            The default whenExhaustedAction setting is WHEN_EXHAUSTED_BLOCK and the default maxWait setting is -1.
+            By default, therefore, borrowObject will block indefinitely until an idle instance becomes available.
+        -->
+        <argument value="WHEN_EXHAUSTED_BLOCK" /> <!-- whenExhaustedAction -->
+        <!--
+            the maximum amount of time to wait for an idle object when the pool is exhausted and whenExhaustedAction
+            is WHEN_EXHAUSTED_BLOCK (otherwise ignored)
+        -->
+        <argument value="-1" /> <!-- maxWait -->
+        <!--
+            controls the maximum number of objects that can sit idle in the pool at any time.
+            When negative, there is no limit to the number of objects that may be idle at one time.
+            The default setting for this parameter is 8.
+        -->
+        <argument value="8" /> <!-- maxIdle -->
+        <!--
+           sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns
+           new objects.
+        -->
+        <argument value="0" /> <!-- minIdle -->
+        <!--
+            when true, objects will be validated before being returned by the borrowObject() method.
+        -->
+        <argument value="false" /> <!-- testOnBorrow -->
+        <!--
+            when true, objects will be validated before being returned to the pool within the returnObject(T).
+        -->
+        <argument value="false" /> <!-- testOnReturn -->
+        <!--
+            sets the number of milliseconds to sleep between runs of the idle object evictor thread.
+        -->
+        <argument value="-1" /> <!-- timeBetweenEvictionRunsMillis -->
+        <!--
+            the number of idle objects to examine per run within the idle object eviction thread (if any)
+        -->
+        <argument value="3" /> <!-- numTestsPerEvictionRun -->
+        <!--
+            sets the minimum amount of time an object may sit idle in the pool before it is eligible for eviction by
+            the idle object evictor (if any). When non-positive, no objects will be evicted from the pool due to idle
+            time alone.
+        -->
+        <argument value="1800000" /> <!-- minEvictableIdleTimeMillis -->
+        <!--
+            when true, objects will be validated by the idle object evictor (if any). If an object fails to validate,
+            it will be dropped from the pool.
+        -->
+        <argument value="false" /> <!-- testWhileIdle -->
+        <!--
+            softMinEvictableIdleTimeMillis specifies the minimum amount of time an object may sit idle in the pool before
+            it is eligible for eviction by the idle object evictor (if any), with the extra condition that at least "minIdle"
+            object instances remain in the pool. When non-positive, no objects will be evicted from the pool due to idle time alone.
+            This setting has no effect unless timeBetweenEvictionRunsMillis > 0. and it is superceded by
+            minEvictableIdleTimeMillis (that is, if minEvictableIdleTimeMillis is positive, then
+            softMinEvictableIdleTimeMillis is ignored). The default setting for this parameter is -1 (disabled).
+        -->
+        <argument value="-1" /> <!-- softMinEvictableIdleTimeMillis -->
+        <!--
+            lifo determines whether or not the pool returns idle objects in last-in-first-out order. The default setting for this parameter is true.
+        -->
+        <argument value="true" /> <!-- lifo -->
+    </bean>
+
+    <bean id="pooledConnectionFactory" class="org.apache.commons.dbcp.PoolableConnectionFactory" >
+        <argument ref="connectionFactory" />
+        <argument ref="connectionPool" />
+        <argument><null/></argument>
+        <!--
+            a query to use to validate Connections. Should return at least one row. Using null turns off validation.
+        -->
+        <argument><null/></argument> <!-- validationQuery -->
+        <!--
+            the default "read only" setting for borrowed connections
+        -->
+        <argument value="false" /> <!-- defaultReadOnly -->
+        <!--
+            the default "auto commit" setting for returned connections
+        -->
+        <argument value="true" /> <!-- defaultAutoCommit -->
+    </bean>
+
+    <bean id="pooledDataSource" class="org.apache.commons.dbcp.PoolingDataSource" depends-on="pooledConnectionFactory">
+        <argument ref="connectionPool" />
+    </bean>
+
+    <service ref="pooledDataSource" interface="javax.sql.DataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+
+</blueprint>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/karaf/blob/36761d5d/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-h2.xml
----------------------------------------------------------------------
diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-h2.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-h2.xml
new file mode 100644
index 0000000..9fd9d1d
--- /dev/null
+++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-h2.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="dataSource" class="org.h2.jdbcx.JdbcDataSource">
+        <property name="URL" value="${url}"/>
+        <property name="user" value="${user}"/>
+        <property name="password" value="${password}"/>
+    </bean>
+
+    <service interface="javax.sql.DataSource" ref="dataSource">
+        <service-properties>
+            <entry key="osgi.jndi.service.name" value="jdbc/${name}"/>
+        </service-properties>
+    </service>
+</blueprint>
\ No newline at end of file