From d89d1eec6de88b5f2c706433b7a0b8fb94dcc5cb Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 20 Jul 2016 17:05:41 +0530 Subject: [PATCH] framework/db: add checkConnection method Signed-off-by: Rohit Yadav --- .../db/src/com/cloud/utils/db/TransactionLegacy.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/framework/db/src/com/cloud/utils/db/TransactionLegacy.java b/framework/db/src/com/cloud/utils/db/TransactionLegacy.java index 7784d2f4399..fc2502c849d 100755 --- a/framework/db/src/com/cloud/utils/db/TransactionLegacy.java +++ b/framework/db/src/com/cloud/utils/db/TransactionLegacy.java @@ -177,6 +177,16 @@ public class TransactionLegacy implements Closeable { return txn; } + public void checkConnection() { + try { + if (_conn != null && !_conn.isValid(3)) { + _conn = null; + } + } catch (SQLException e) { + _conn = null; + } + } + protected StackElement peekInStack(Object obj) { final Iterator it = _stack.iterator(); while (it.hasNext()) {