Closed salman-khandu closed 6 years ago
Connection
to a static variable. Think of concurrency issues that might occur.Just read my book High-Performance Java Persistence for more details.
You should never assign a Connection to a static variable. Think of concurrency issues that might occur. <-- I have just run sample test with the same method by 1000 threads where I didn't get any error.
Why this error java.sql.SQLException: Invalid state, the Statement object is closed occurred? is statement object close automatically in exception case?
Thank you
Why this error java.sql.SQLException: Invalid state, the Statement object is closed occurred? is statement object close automatically in exception case?
If you only get it from time to time, only logging will help you determine what triggered it.
Error occurred only in some cases. How can I configure logs to determine it?
Thank you
Just read my book and you'll find the answer to all these questions.
Thank you vlad
When I check oracle doc https://docs.oracle.com/javase/tutorial/jdbc/basics/processingsqlstatements.html
then close statment by if (stmt != null) { stmt.close(); }
I have following code.
con is static class variable initialize with the method getConnection() . Exception throws from execute method handle by caller method.
In most cases, it works fine but in some cases, it will give error "java.sql.SQLException: Invalid state, the Statement object is closed" when I call stmt.close() in finally block. What is the possibility of occurring such error?
Thank you Salman