Displaying differences for changeset
 
display as  

src/org/csu/csip/sdm/SDMResultSet.java

@@ -85,7 +85,7 @@
         } else {
             //  The USDA REST service for SDM returns an empty JSONObject when the result
             //of the query had no return values.  Assume here that the query suceeded but had no results.
-            
+
             //throw new SQLException("Invalid results from database. No Table object found");
         }
     }
@@ -1162,21 +1162,23 @@
 
     private class ResultRow {
 
-        private ArrayList<String> values = new ArrayList<>();
+        private final JSONArray values;
 
         public ResultRow(JSONArray inputValues) throws JSONException {
-
-            for (int i = 0; i < inputValues.length(); i++) {
-                values.add(inputValues.getString(i));
-            }
+            values = inputValues;
         }
 
         public String getValue(int index) throws SQLException {
-            if ((index >= 0) && (index < values.size())) {
-                return values.get(index);
+            if ((index >= 0) && (index < values.length()) ) {
+                try {
+                    return values.getString(index);
+                } catch (JSONException ex) {
+                    Logger.getLogger(SDMResultSet.class.getName()).log(Level.SEVERE, null, ex);
+                    throw new SQLException("Invalid index used in row operation: getValue: " + ex.getMessage());
+                }
             } else {
                 throw new SQLException("Invalid index used in row operation: getValue");
             }
         }
-    }           
+    }
 }