Empty string difference between MS SQL Server 2005 and 2008

Hi,

I just noticed that there is a difference between MS SQL Server 2005 and 2008 in combination with Servoy.

With MSSQL 2005 an empty string was written to the database as NULL value
With MSSQL 2008 an empty string is written to the database as an empty string

Is this difference caused by Servoy, the JDBC-driver or Servoy?
Probably not Servoy because it happens on both Servoy 4.1.6 and Servoy 5.1.4.

I tested not only with the JDBC driver provided by Servoy, but also with the latest jtds.jar driver and both show this same situation.

Is there some setting to get the old behavior again, or do I need to test not only on NULL in my application, but also in empty string values?

Martin

martinh:
Is this difference caused by Servoy, the JDBC-driver or Servoy?
Probably not Servoy because it happens on both Servoy 4.1.6 and Servoy 5.1.4.

Martin,

Servoy sends empty strings as such to the driver.

Rob

Rob,

Has this behavior been changed? Because I’m quite sure that in the past an empty string was written to the database as a null value.

Martin

There is something very strange:

I have an existing TEXT-field with NULL value not allowed.

When I put

databaseManager.nullColumnValidatorEnabled = true

and I empty the field, then Servoy shows me an error:

Validation failed for ‘relation_code’, with value:

java.lang.IllegalArgumentException: Validation failed for ‘relation_code’, with value:

This is the behavior that I expect. So the empty field is considered as NULL value for Servoy.

But when I set

databaseManager.nullColumnValidatorEnabled = false

and I empty the existing field, then it is considered as an empty string and not as NULL-value.

That isn’t very logic. If an error is triggered when nullColumnValidatorEnabled = true, then Servoy sees this as a null value. So why when nullColumnValidatorEnabled = false, the field isn’t seen as null value?

Martin,

I don’t think this behaviour has changed in Servoy.
We have been sending null or empty to the db as received, but some databases (like apparently sqlserver 2005) were saving empty string as null.

The null-check in Servoy does, however, treat null and empty strings the same, you are right.

Rob