This question is 40 points, not 20 points.
I have a big registration form. I wrote myTextField extending TextField
in order to make sure that there are no problem in doing INSERT and UPDATE
when the user just inputs some of these text fields. The following piece of
code getText() in myTextField is OK for value of data type "Text" in database, but for
the value of data type "Number" in database will cause syntax error. I need a correct
query = "UPDATE regist " +
"SET lastName = '" + txtlastName + "'," +
"TotalBal = " + txtTotalBal.getText() +
" WHERE bibNo = 100 ";
If the text fields are blank, the query is:
UPDATE regist SET lastName = '',TotalBal = WHERE bibNo = 100
The value of TotalBal should be 0, not empty.
public String getText()
String s = super.getText();
if(s == null) return new String();