From 3c0f2494922544550a5c6bb3300ea737e63e3d5a Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 20 Oct 2022 22:03:54 -0400 Subject: [PATCH] set value as NULL if getString returns null an wasNull fails --- app/src/main/java/jrunner/jrunner.java | 77 ++++++++++++++------------ 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/jrunner/jrunner.java b/app/src/main/java/jrunner/jrunner.java index 0036ddc..6ed05f1 100644 --- a/app/src/main/java/jrunner/jrunner.java +++ b/app/src/main/java/jrunner/jrunner.java @@ -193,44 +193,49 @@ public class jrunner { nr = ""; for (int i = 1; i <= cols; i++){ nc = rs.getString(i); - if (rs.wasNull()) { + if (dtn[i] == "DATE" && nc == "null") { nc = "NULL"; - } else { - switch (dtn[i]){ - case "VARCHAR": - nc = rs.getString(i).replace("'","''"); - if (trim) { nc = nc.trim();} - nc = "'" + nc + "'"; - break; - case "CLOB": - nc = rs.getString(i).replace("'","''"); - if (trim) { nc = nc.trim();} - nc = "'" + nc + "'"; - break; - case "CHAR": - nc = rs.getString(i).replace("'","''"); - if (trim) { nc = nc.trim();} - nc = "'" + nc + "'"; - break; - case "DATE": - nc = "'" + rs.getString(i) + "'"; - if (nc == "'1/1/0001 12:00:00 AM'") { - nc = "NULL"; - } - break; - case "TIME": - nc = "'" + rs.getString(i).replace("'","''") + "'"; - break; - case "BIGINT": - nc = rs.getString(i); - default: - if (rs.getString(i) != "") { + } + else { + if (rs.wasNull()) { + nc = "NULL"; + } else { + switch (dtn[i]){ + case "VARCHAR": + nc = rs.getString(i).replace("'","''"); + if (trim) { nc = nc.trim();} + nc = "'" + nc + "'"; + break; + case "CLOB": + nc = rs.getString(i).replace("'","''"); + if (trim) { nc = nc.trim();} + nc = "'" + nc + "'"; + break; + case "CHAR": + nc = rs.getString(i).replace("'","''"); + if (trim) { nc = nc.trim();} + nc = "'" + nc + "'"; + break; + case "DATE": + nc = "'" + rs.getString(i) + "'"; + if (nc == "'1/1/0001 12:00:00 AM'") { + nc = "NULL"; + } + break; + case "TIME": + nc = "'" + rs.getString(i).replace("'","''") + "'"; + break; + case "BIGINT": nc = rs.getString(i); - } - else { - nc = "NULL"; - } - break; + default: + if (rs.getString(i) != "") { + nc = rs.getString(i); + } + else { + nc = "NULL"; + } + break; + } } } if (i != 1){