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
This commit is contained in:
parent
630878bb50
commit
a3d512e5d3
1 changed files with 15 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue