Skip to Content.
Sympa Menu

freetds - [JDBC] Patch, empty CHAR columns are treated as NULL values

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Stefan Bodewig <bodewig AT bost.de>
  • To: <freetds AT franklin.oit.unc.edu>
  • Cc: freetds-jdbc-bugs AT internetcds.com
  • Subject: [JDBC] Patch, empty CHAR columns are treated as NULL values
  • Date: 08 Nov 2000 14:23:28 +0100

Hi,

when using TDS version 7.0 the JDBC driver will claim empty CHAR
columns would contain NULLs. The appended patch fixes this problem

Stefan

Index: Tds.java
===================================================================
RCS file: /Repository/freetds_jdbc/Tds.java,v
retrieving revision 1.53
diff -u -r1.53 Tds.java
--- Tds.java	2000/07/17 04:41:06	1.53
+++ Tds.java	2000/11/08 13:20:31
@@ -1999,22 +1999,24 @@
       Object result;
       int     len = tdsVer == Tds.TDS70 ? comm.getTdsShort() : comm.getByte() & 0xFF;
 
-      if (len == 0 || tdsVer == Tds.TDS70 && len == 0xFFFF)
+      if ((tdsVer != Tds.TDS70 && len == 0) 
+          || 
+          (tdsVer == Tds.TDS70 && len == 0xFFFF))
       {
          result = null;
       }
-      else if (len > 0)
+      else if (len >= 0)
       {
          if (wideChars)
             result = comm.getString(len / 2);
          else
             result = encoder.getString(comm.getBytes(len));
 
-         if (result.equals(" "))
+         if (result.equals(" ") && tdsVer != Tds.TDS70)
          {
             // In SQL trailing spaces are stripped from strings
             // MS SQLServer denotes a zero length string
-            // as a single space.
+            // as a single space when using TDS 4.2.
             result = "";
          }
       }


  • [JDBC] Patch, empty CHAR columns are treated as NULL values, Stefan Bodewig, 11/08/2000

Archive powered by MHonArc 2.6.24.

Top of Page