What happens with the connection established with database if a instance of java.sql.Connection as con is nullified.
con = null;
Is the connection closed or remains open till the application is running.
2nd Question :
Similarly if have an instance of javax.mail.Store as store and nullify it ,
store = null;
will the smtp connection be closed or remains unclosed.
Thanks.
If you set your
Connectionto null, this connection will remain “open” and the code associated with close will not be run. Hence in order to close it you must call theclose()method.If the connection is not closed, other resources that might be held by the connection won’t be released either