You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@karaf.apache.org by "Jean-Baptiste Onofré (JIRA)" <ji...@apache.org> on 2014/05/04 17:43:14 UTC

[jira] [Updated] (KARAF-2941) Let jdbc be more robust against broken data sources

     [ https://issues.apache.org/jira/browse/KARAF-2941?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jean-Baptiste Onofré updated KARAF-2941:
----------------------------------------

    Fix Version/s: 2.3.6
                   3.0.2
                   4.0.0
                   2.4.0

> Let jdbc be more robust against broken data sources
> ---------------------------------------------------
>
>                 Key: KARAF-2941
>                 URL: https://issues.apache.org/jira/browse/KARAF-2941
>             Project: Karaf
>          Issue Type: Improvement
>          Components: karaf-shell
>            Reporter: Mike Hummel
>            Assignee: Jean-Baptiste Onofré
>             Fix For: 2.4.0, 4.0.0, 3.0.2, 2.3.6
>
>
> Currently if you call jdbc:datasources with a broken datasource it will output nothing useful.
> It should be more robust. To make it easy I have a patch for you (version 3.0.1). Have a look at it:
> 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
> index 36df691..dd3a599 100644
> --- 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
> @@ -21,10 +21,14 @@
>  
>  import java.util.List;
>  import java.util.Map;
> +import java.util.logging.Level;
> +import java.util.logging.Logger;
>  
>  @Command(scope = "jdbc", name = "datasources", description = "List the JDBC datasources")
>  public class DataSourcesCommand extends JdbcCommandSupport {
>  
> +	Logger LOG = Logger.getLogger(DataSourcesCommand.class.getName());
> +	
>      public Object doExecute() throws Exception {
>          ShellTable table = new ShellTable();
>  
> @@ -35,8 +39,14 @@
>  
>          List<String> datasources = this.getJdbcService().datasources();
>          for (String datasource : datasources) {
> -            Map<String, String> info = this.getJdbcService().info(datasource);
> -            table.addRow().addContent(datasource, info.get("db.product"), info.get("db.version"), info.get("url"));
> +        	try {
> +        		Map<String, String> info = this.getJdbcService().info(datasource);
> +        		table.addRow().addContent(datasource, info.get("db.product"), info.get("db.version"), info.get("url"));
> +        	} catch (Throwable t) {
> +        		LOG.log(Level.WARNING,"Working on datasource: " + datasource,t);
> +        		table.addRow().addContent(datasource, "error", "", t.getMessage());
> +        		
> +        	}
>          }
>  
>          table.print(System.out);



--
This message was sent by Atlassian JIRA
(v6.2#6252)