I was debugging some old Java code and it seems it hangs here
PreparedStatement myStatement;
some code.....
try {
if (!myStatement.isClosed()) {
myStatement.close();
}
}
Now, I can't debug this directly in Netbeans, but I can compile a new jar file with log4j statements and it seems to be stuck at the if statement.
Was using ojdbc14-10.2.0.5.0.jar Oracle driver on Oracle 11g DB.
I'm guessing you are calling the close()
method in a finalizer. Try using this way:
try {
myStatement = ...
...// execute or fetch...
} finally {
if(myStatement != null)
myStatement.close();
}
Calling close()
for an already closed statement does nothing so its not a problem. You can always remove the isClosed()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.