I have to program a Web Crawler (uni assignment), thus I have to store/read/update lots of data to/from a MySQL Database.
I'm using JDBC connector and on every-time I call a method to contact the database I'm defining a PreparedStatement & ResultSet and finally i close the RS and finally the PS.
However I use the same methods so many times that instead of making the program more Time/Resource Efficient I'm making it slower/heavier (that's why I don't close the connection too). So the question is there any other reason to close those or should I let them open?
If I don't close them the program seems not to have any issue but I don't want it to seem correct but truly be.
Edit: Thanks for the ideas on how to close but the question is not How to but "Is it mandatory". Closing makes the program slow so I need to know if I cannot close (seems that it's bad practise) or at least find a better alternative.