I have a program that starts up the Derby Network Server using the NetworkServerControl API and when I want to shut down the network server, I want to be done gracefully so that no new transactions will start, but all current transactions are given a set amount of time to finish. I see that the API has a shutdown command, but it does not say anything about current ongoing transactions from client connections and whether or not it just kills the process immediately. Does the Derby Network Server handle current and new transactions automatically, or is there a method to stop new client connections and transactions?
I was thinking (and this might be completely wrong) that I could use call setMaxThreads(0) to stop JDBC client connections, but I am not sure what will happen to ongoing transact开发者_运维技巧ions if I do.
Thanks in advance.
Consider using table locks to do this. Write a special program which takes table locks on all your important tables, then shuts down the network server.
http://db.apache.org/derby/docs/10.8/ref/rrefsqlj40506.html
DriverManager.getConnection("jdbc:derby:MyDbTest;shutdown=true");
This will close the database gracefully.
精彩评论