@@ -61,9 +61,6 @@ |
throw new SQLException("Invalid results from database. No Table object found"); |
} |
maxRows = mainTable.length() - 1; //First row is the column names |
- if (maxRows > 0) { |
- rowId = 0; |
- } |
|
JSONArray tempRow; |
try { |
@@ -140,6 +137,9 @@ |
throw new SQLException("ResultSet is empty, no column lables are found."); |
} |
|
+ if ( ret_val == -1 ){ |
+ throw new SQLException("Column was not found in the ResultSet: " + columnLabel); |
+ } |
return ret_val; |
} |
|
@@ -296,7 +296,10 @@ |
public double getDouble(int columnIndex) throws SQLException { |
String value = rows.get(rowId).getValue(columnIndex); |
|
- return Double.parseDouble(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Double.parseDouble(value); |
+ } |
+ return Double.NaN; |
} |
|
@Override |
@@ -304,7 +307,10 @@ |
int index = findColumn(columnLabel); |
String value = rows.get(rowId).getValue(index); |
|
- return Double.parseDouble(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Double.parseDouble(value); |
+ } |
+ return Double.NaN; |
} |
|
@Override |
@@ -331,7 +337,10 @@ |
public float getFloat(int columnIndex) throws SQLException { |
String value = rows.get(rowId).getValue(columnIndex); |
|
- return Float.parseFloat(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Float.parseFloat(value); |
+ } |
+ return Float.NaN; |
} |
|
@Override |
@@ -339,7 +348,10 @@ |
int index = findColumn(columnLabel); |
String value = rows.get(rowId).getValue(index); |
|
- return Float.parseFloat(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Float.parseFloat(value); |
+ } |
+ return Float.NaN; |
} |
|
@Override |
@@ -351,7 +363,10 @@ |
public int getInt(int columnIndex) throws SQLException { |
String value = rows.get(rowId).getValue(columnIndex); |
|
- return Integer.parseInt(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Integer.parseInt(value); |
+ } |
+ return Integer.MAX_VALUE; |
} |
|
@Override |
@@ -359,14 +374,20 @@ |
int index = findColumn(columnLabel); |
String value = rows.get(rowId).getValue(index); |
|
- return Integer.parseInt(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Integer.parseInt(value); |
+ } |
+ return Integer.MAX_VALUE; |
} |
|
@Override |
public long getLong(int columnIndex) throws SQLException { |
String value = rows.get(rowId).getValue(columnIndex); |
|
- return Long.parseLong(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Long.parseLong(value); |
+ } |
+ return Long.MAX_VALUE; |
} |
|
@Override |
@@ -374,7 +395,10 @@ |
int index = findColumn(columnLabel); |
String value = rows.get(rowId).getValue(index); |
|
- return Long.parseLong(value); |
+ if ((null != value) && !value.equalsIgnoreCase("null")) { |
+ return Long.parseLong(value); |
+ } |
+ return Long.MAX_VALUE; |
} |
|
@Override |
@@ -625,7 +649,7 @@ |
|
@Override |
public boolean next() throws SQLException { |
- if ((maxRows > 0) && (rowId < maxRows)) { |
+ if ((maxRows > 0) && (rowId < (maxRows-1))) { |
rowId++; |
return true; |
} |