I'm actually having an JSP Form in a single page.
Well, we can say it is a static one. But
my case here is that, if there's nobody enter any value into the form...
Then the textfields there would be a STRING that has a length of 0.
Thus, I wanted to use that NOT To be stored into the (Database) db that I used.
Instead I want to use its default value.
Here I use to create the insertion occured in mysql utility that I made;
But, if I put that way... then the Order1 variable is not getting the default value for them,
Then if I set my beans into a "DEFAULT" ---> String. also it will not making the Column insert its default value.
J. Insi wrote:well, ya ... I mean, the table of that mysql is already assigned using DEFAULT value.
Such as its values from :
I already set them with : "-" as the default value.
But, here the case is... what String value that I need to pass upon
the values of :
Because, If I pass null or empty string (" ") into the setString as below ;
it won't pass the default value... even If, let say I one of them become NULL, and it's set...
still, the query passing over the values not the DEFAULT.
~ correct me if i'm wrong.
It is normal for JavaJ2EE applications, if you set them with empty strings then those columns will store empty string value inside the columns defined.
Firstly, you should check the value in your Java code and validate the getString method for NULL or empty strings. Validation inside Java Code is required if you don't want to set (empty or NULL).
You should decide by using simple if/else logic and checking NULL or empty string. After checking values you can use setString method for those columns with DEFAULT like below;
INSERT table VALUES (DEFAULT, NULL, 'WA', DEFAULT,.....) I mean use setString method like this setString(1,'DEFAULT')
If you use setString method, naturally it will change(override) the default value.
Otherwise how can you set NULL or empty string for those colums??? That's case. ? got it ?
Joined: Aug 11, 2010
ok i got it!
OMG. i have a bunch of code like this in another apps....