Hello everyone! During my programming practice, when I attempted to assign a column of null value from a MySQL database to a string variable, an error occurred when using this string variable again, and it was very difficult to pinpoint the row where the error occurred:
java.lang.Exception: java.lang.NullPointerException.
Without using the database statement "IFNULL(`field name`, '')" to specify a default value for it, how can I determine its length?
java.lang.Exception: java.lang.NullPointerException.
Without using the database statement "IFNULL(`field name`, '')" to specify a default value for it, how can I determine its length?
B4X:
Dim sqlstr As String = "SELECT * FROM `db1` WHERE `col1` = ? AND `col2` = ? ORDER BY `col4` DESC LIMIT 1;"
Dim Cursor As ResultSet = sql.ExecQuery2(sqlstr,Array As Object("xxx","xxxx"))
Dim success_time As String
Do While Cursor.NextRow
success_time = Cursor.GetString("col1") 'col1 has a null value.
Loop
if success_time.length > 0 then 'The problem occurs in this line.