1036
Vývoj / Re:Java - Finally neprobehne vzdy
« kdy: 11. 04. 2016, 18:24:01 »Zdravim,Jak píšou jiní, to je záležitost databáze, ne Javy, chce to prostě nějaký timeout na nečekaně ukončená spojení.
zde pisou:
http://stackoverflow.com/questions/516049/in-java-is-the-finally-block-guaranteed-to-be-called-in-the-main-methodCitace
down vote
In a word, yes.
Code in the finally block in Java always executes unless:
The JVM exits during the try or catch block
The thread running the code is interrupted or killed during the try or catch block
(from: http://java.sun.com/docs/books/tutorial/essential/exceptions/finally.html)
So, unless you explicitly call System.exit(int), or kill the process or thread externally, you can rely on it.
Co tedy delat v pripade, mam-li napriklad pripojeni k oracle databazi, nebo jeste hur, mam X pripojeni k databazi a vkladam paralelne, a proces je zvenci v konzoli ukoncen, napr. pres CTRL+C ?
Connection se ve Finally neuzavre a zustane visit. To muze klidne zablokovat pristup do DB. Vcelku zavazna vec. Jak z toho ven?

A pleteš si pády