diff options
author | bolbic <bolbic@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-22 20:10:33 +0000 |
---|---|---|
committer | bolbic <bolbic@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-22 20:10:33 +0000 |
commit | a3d512e5d30a8057b8bb61280c2447a5938de0df (patch) | |
tree | 83ccaaa33787dec9d63110e276a5fda4e1b7b1b0 | |
parent | 630878bb5086dd600e9746c1ac4962a3f18d9419 (diff) |
when result descriptor count doesn't match result column count, truncate result descriptors
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1084336 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java b/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java index c78d91e219..7d3567af9f 100644 --- a/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java +++ b/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/impl/ReadCommandImpl.java @@ -20,6 +20,8 @@ package org.apache.tuscany.das.rdb.impl; import java.io.IOException; import java.io.OutputStream; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; @@ -272,8 +274,21 @@ public class ReadCommandImpl extends CommandImpl { boolean success = false; try { + // execute query List results = statement.executeQuery(parameters); success = true; + // if result set contains less columns than result descriptors, crop result descriptors + if (resultDescriptors != null && results.size() > 0) { + ResultSet resultSet = (ResultSet) results.get(0); + ResultSetMetaData resultSetMetadata = resultSet.getMetaData(); + int columnCount = resultSetMetadata.getColumnCount(); + int resultDescriptorCount = resultDescriptors.size(); + if (resultDescriptorCount > columnCount) { + resultDescriptors = resultDescriptors.subList(0, columnCount); + refreshResultSetShape(); + } + } + // build graph return buildGraph(results); } catch (SQLException e) { throw new RuntimeException(e); |