I understand that jdbc involved these steps
- Import the packages,
- Register the JDBC driver,
- Open a connection,
- Execute a query,
- Extract data from result set,
- Clean up the environment.
I have 2 java files one is for GUI (Swing) and another is normal Java file. I have many input fields in GUI and send them to backend file for processing using JDBC. I have many methods like this in my Java file. The problem is in each method I have to the entire steps (mentioned above) in each of these methods. As a result of this it has become slow. I wanted to optimize it making first 3 steps and final steps mentioned above only once.
How to achieve this?
Sounds like you need a
Connection Pool. There are lots of questions related to connection pooling on Stack Overflow – there’s even a tag for it!https://stackoverflow.com/questions/tagged/connection-pooling