Repository: karaf Updated Branches: refs/heads/master a9dbfad89 -> 7591761c6
[KARAF-2848] Add MSSQL datasource support Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/7591761c Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/7591761c Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/7591761c Branch: refs/heads/master Commit: 7591761c65a3e3dfc040d9b28c1dc116ad61a297 Parents: a9dbfad Author: Jean-Baptiste Onofré <[email protected]> Authored: Mon Apr 7 15:39:38 2014 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Mon Apr 7 15:39:38 2014 +0200 ---------------------------------------------------------------------- .../karaf/jdbc/command/CreateCommand.java | 4 +-- .../java/org/apache/karaf/jdbc/JdbcMBean.java | 2 +- .../karaf/jdbc/internal/JdbcServiceImpl.java | 1 + .../karaf/jdbc/internal/datasource-mssql.xml | 32 ++++++++++++++++++++ manual/src/main/webapp/users-guide/jdbc.conf | 4 +-- 5 files changed, 38 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/7591761c/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 index 39f638e5..89ed49c 100644 --- 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 @@ -30,8 +30,8 @@ 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) - @Completion(value = StringsCompleter.class, values = { "db2", "derby", "generic", "h2", "hsql", "mysql", "oracle", "postgres" }) + @Option(name = "-t", aliases = { "--type" }, description = "The JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby, MSSQL)", required = false, multiValued = false) + @Completion(value = StringsCompleter.class, values = { "db2", "derby", "generic", "h2", "hsql", "mysql", "oracle", "postgres", "mssql" }) 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) http://git-wip-us.apache.org/repos/asf/karaf/blob/7591761c/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 index f899874..26165c8 100644 --- a/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java +++ b/jdbc/core/src/main/java/org/apache/karaf/jdbc/JdbcMBean.java @@ -37,7 +37,7 @@ public interface JdbcMBean { * Create a JDBC datasource. * * @param name the JDBC datasource name. - * @param type the JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby). + * @param type the JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby, MSSQL). * @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. http://git-wip-us.apache.org/repos/asf/karaf/blob/7591761c/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 index e1f65af..50cf8ff 100644 --- 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 @@ -42,6 +42,7 @@ public class JdbcServiceImpl implements JdbcService { H2("mvn:com.h2database/h2/", "1.3.163", "datasource-h2.xml"), HSQL("mvn:org.hsqldb/hsqldb/", "2.3.2", "datasource-hsql.xml"), MYSQL("mvn:mysql/mysql-connector-java/", "5.1.18", "datasource-mysql.xml"), + MSSQL("wrap:mvn:net.sourceforge.jtds/jtds/", "1.2.4", "datasource-mssql.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"); http://git-wip-us.apache.org/repos/asf/karaf/blob/7591761c/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mssql.xml ---------------------------------------------------------------------- diff --git a/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mssql.xml b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mssql.xml new file mode 100644 index 0000000..35e6ed9 --- /dev/null +++ b/jdbc/core/src/main/resources/org/apache/karaf/jdbc/internal/datasource-mssql.xml @@ -0,0 +1,32 @@ +<?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="dataSource" class="net.sourceforge.jtds.jdbcx.JtdsDataSource"> + <property name="serverName" value="${url}"/> + <property name="databaseName" value="${name}"/> + <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> http://git-wip-us.apache.org/repos/asf/karaf/blob/7591761c/manual/src/main/webapp/users-guide/jdbc.conf ---------------------------------------------------------------------- diff --git a/manual/src/main/webapp/users-guide/jdbc.conf b/manual/src/main/webapp/users-guide/jdbc.conf index 1e3210f..302a9fc 100644 --- a/manual/src/main/webapp/users-guide/jdbc.conf +++ b/manual/src/main/webapp/users-guide/jdbc.conf @@ -40,7 +40,7 @@ OPTIONS -v, --version The version of the driver to use -t, --type - The JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby) + The JDBC datasource type (generic, MySQL, Oracle, Postgres, H2, HSQL, Derby, MSSQL) -url The JDBC URL to use -p, --password @@ -57,7 +57,7 @@ OPTIONS * the {{name}} argument is required. It's the name of the datasource. The name is used to identify the datasource, and to create the datasource definition file ({{deploy/datasource-[name].xml}}). * the {{-u}} option is optional. It defines the database username. * the {{-v}} option is optional. It "forces" a given JDBC driver version (only used with the {{-i}} option). -* the {{-t}} option is required. It defines the JDBC datasource type. Accepted values are: MySQL, Oracle, Postgres, Derby, H2, HSQL, Generic. Generic is a generic configuration file using DBCP to create a pooled datasource. When using generic, it's up to you to install the JDBC driver and configure the {{deploy/datasource-[name].xml}} datasource file. +* the {{-t}} option is required. It defines the JDBC datasource type. Accepted values are: MySQL, Oracle, Postgres, Derby, H2, HSQL, MSSQL, Generic. Generic is a generic configuration file using DBCP to create a pooled datasource. When using generic, it's up to you to install the JDBC driver and configure the {{deploy/datasource-[name].xml}} datasource file. * the {{-url}} option is optional. It defines the JDBC URL to access to the database. * the {{-p}} option is optional. It defines the database password. * the {{-d}} option is optional. It defines the JDBC driver classname to use (only used with the generic type).
