B4J Question Necessity of closing databases and resultsets?

Hello.
Is it necessary to call the "close" method on a database once we're done with it?
What about result sets? Is it necessary to close them?
Thanks in advance.
 

Erel

Administrator
Staff member
Licensed User
I assume that you are asking about SQLite databases.
Is it necessary to call the "close" method on a database once we're done with it?
The database will be "closed" when the process exits. Nothing bad will happen.

What about result sets? Is it necessary to close them?
Yes, you should close them to avoid leaking resources.

Most important is to finish transactions.
 
Thank you so much Erel.
Actually I'm using mySQL.
So, I will close result sets and make sure transactions end with either sql1.TransactionSuccessful or sql1.RollBack
 

amykonio

Member
Licensed User
I assume that you are asking about SQLite databases.

The database will be "closed" when the process exits. Nothing bad will happen.

.
Hi Erel.

Is this the way it works with b4x? Does it close the connection(s) when the program finish? I've seen many times connections in sql servers that aren't really valid because a database connection wasn't properly closed at the end. This is not really an issue when you are working with a database with unlimited client connections. The server will probably kill them after awhile. But if there is a limit? Personally I always close the connections.

Andreas.
 
Top