B4J Question Result Set close on error

Philip Prins

Active Member
Licensed User
Longtime User
Hello,

Do you need to close the resultset or cursor when you use Try Catch ?

Example
Example:
Try

        Dim RS As ResultSet =
        
        Do While
        
        Loop
        
        
        RS.close
        
Catch
        RS.close 'Is this neccesary?
End Try
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is probably an overkill.

Note that you can write it like this:
B4X:
Try

        Dim RS As ResultSet =
        
        Do While
        
        Loop
        
        
        
Catch
    Log(LastException)
End Try
  RS.close

Assuming that it is a local SQLite db then there is no real reason for an unexpected error to happen. If it is a remote db then you should use a pool and make sure to close the connection (which will close other resources as well).
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…