I have an tomcat application page that stores data from a form to a mysql datasource running on the server. Many of the form fields are simple text fields where the user can leave the field blank when filling out the form. The parameter values from the form are passed to the preceding jsp page that executes the <sql:update dataSource="${my_db_data}"> using the Java Standard Tag Library. I'll past below a snippet from the code:
<sql:update dataSource="${my_db_data}"> INSERT INTO my_database_table (firstname, middlename, lastname, suffix, email_address.... and on it goes listing fields from the database) VALUES (?, ?, ?, ?....... and on it goes listing ? marks equal tothe number of values above) <sql:param value="${param.firstName}" /> <sql:param value="${param.middleName}" /> <sql:param value="${param.lastName}" /> <sql:param value="${param.suffix}" /> <sql:param value="${param.emailAddress}" /> The problem I have is: if the user left a field blank on the form, say the email_address, the value that gets passed to the database is a blank ('') field value. However, I want the email_address field to have a UNIQUE Index within the database and that is not possible if there are multiple records with blank ('') field values for the email_address because MySQL counts such values as tangible capable of enforcing the index on... unlike how it would ignore email address that had the value of NULL. I need the emailAddress field to store as NULL instead of a blank ('') field in order to have the UNIQUE Index in the MySQL db. With the implementation as it is above, the field doesn't save as NULL. How do I get it to? just ferindo