Changeset: 9df089b0d69d for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=9df089b0d69d
Modified Files:
src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
Branch: default
Log Message:
Improve performance of ResulSet methods getDate(), getTime() getTimestamp()
in case the value is NULL.
diffs (54 lines):
diff --git a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
--- a/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
+++ b/src/main/java/nl/cwi/monetdb/jdbc/MonetResultSet.java
@@ -2782,6 +2782,16 @@ public class MonetResultSet extends Mone
public java.sql.Date getDate(int columnIndex, Calendar cal)
throws SQLException
{
+ // to avoid unnecessary work, check for NULL value and invalid
columnIndex first
+ try {
+ if (tlp.values[columnIndex - 1] == null) {
+ lastReadWasNull = true;
+ return null;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw newSQLInvalidColumnIndexException(columnIndex);
+ }
+
if (cal == null) {
cal = Calendar.getInstance();
}
@@ -2860,6 +2870,16 @@ public class MonetResultSet extends Mone
public Time getTime(int columnIndex, Calendar cal)
throws SQLException
{
+ // to avoid unnecessary work, check for NULL value and invalid
columnIndex first
+ try {
+ if (tlp.values[columnIndex - 1] == null) {
+ lastReadWasNull = true;
+ return null;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw newSQLInvalidColumnIndexException(columnIndex);
+ }
+
if (cal == null) {
cal = Calendar.getInstance();
}
@@ -2938,6 +2958,16 @@ public class MonetResultSet extends Mone
public Timestamp getTimestamp(int columnIndex, Calendar cal)
throws SQLException
{
+ // to avoid unnecessary work, check for NULL value and invalid
columnIndex first
+ try {
+ if (tlp.values[columnIndex - 1] == null) {
+ lastReadWasNull = true;
+ return null;
+ }
+ } catch (IndexOutOfBoundsException e) {
+ throw newSQLInvalidColumnIndexException(columnIndex);
+ }
+
if (cal == null) {
cal = Calendar.getInstance();
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list