You did not share your Java Exception, and that would help in formulating an exact answer.
There are two aspects to your program - Java and DB restrictions.
For Java, an empty string is equal to "" (these are double quotes, not single quotes), so if your Java references - a , b & c have this value when the value is empty, I don’t see any problems with PreparedStatement , you you need to worry about the escape sequence in single quotes if you are using PreparedStatement . I'm not sure why you are listing the values as ['foo','',''] , it should be ["foo","",""] .
The second aspect is that your database columns a , b & c may not allow null values due to restrictions, this is a completely different matter and cannot be controlled using Java code. The database table schema must be modified to allow default values in this case.
Discussion of the escape sequence with a single quote is relevant when someone prepares an SQL query by directly adding values to the query string, for example, "insert into foo (a,b,c) values ('foo','','')"; or a WHERE with a='foo' . This method is not recommended due to SQL injection vulnerabilities.
Sabir khan
source share