private void reconnection() throws IOException { logger.log(BasicLevel.WARN, "reconnection in progress - starting"); try { if (ds != null) { // conn = ds.getConnection(); closeConnection(); // attempt to close all connection and recreate DataSource. } logger.log(BasicLevel.WARN, "reconnection in progress - old connection closed"); conn = getConnection(); logger.log(BasicLevel.WARN, "reconnection in progress - getConnection success"); conn.setAutoCommit(false); insertStmt = conn.prepareStatement("INSERT INTO JoramDB VALUES (?, ?)"); updateStmt = conn.prepareStatement("UPDATE JoramDB SET content=? WHERE name=?"); deleteStmt = conn.prepareStatement("DELETE FROM JoramDB WHERE name=?"); } catch (Exception sqle) { sqle.printStackTrace(); throw new IOException(sqle.getMessage()); } logger.log(BasicLevel.WARN, "Database reconnection success"); } }
reconnection(); reconnectLoop = true; delete(dirName, name); reconnectLoop = false; } else {
if (sqle instanceof com.mysql.jdbc.CommunicationsException && !reconnectLoop) { logger.log(BasicLevel.WARN, "Database reconnection problem at list, Reconnecting"); reconnection(); reconnectLoop = true; String[] result = list(prefix); reconnectLoop = false; return result;
reconnection(); reconnectLoop = true; byte[] content = load(dirName, name); reconnectLoop = false; return content;
reconnection(); reconnectLoop = true; save(dirName, name, content); reconnectLoop = false;
/** * Loads the object. * * @return The loaded object or null if it does not exist. * @throws ClassNotFoundException */ public Object loadobj(String dirName, String name) throws IOException, ClassNotFoundException { if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, "loadobj, b4 load call"); byte[] content = load(dirName, name); if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, "loadobj, after load call"); ByteArrayInputStream bis = new ByteArrayInputStream(content); ObjectInputStream ois = new ObjectInputStream(bis); try { Object obj = ois.readObject(); return obj; } catch (Exception e) { String exceptionString = e.toString(); if (exceptionString.indexOf("KNOWN PROBLEM") == -1) { e.printStackTrace(); } throw new IOException(e.getMessage()); } finally { ois.close(); bis.close(); } }
conn = getConnection(); conn.setAutoCommit(false); } catch (IllegalAccessException exc) {
reconnection(); reconnectLoop = true; byte[] content = load(dirName, name); reconnectLoop = false; return content;
reconnection(); reconnectLoop = true; save(dirName, name, content); reconnectLoop = false;
/** * Loads the object. * * @return The loaded object or null if it does not exist. * @throws ClassNotFoundException */ public Object loadobj(String dirName, String name) throws IOException, ClassNotFoundException { if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, "loadobj, b4 load call"); byte[] content = load(dirName, name); if (logger.isLoggable(BasicLevel.DEBUG)) logger.log(BasicLevel.DEBUG, "loadobj, after load call"); ByteArrayInputStream bis = new ByteArrayInputStream(content); ObjectInputStream ois = new ObjectInputStream(bis); try { Object obj = ois.readObject(); return obj; } catch (Exception e) { String exceptionString = e.toString(); if (exceptionString.indexOf("KNOWN PROBLEM") == -1) { e.printStackTrace(); } throw new IOException(e.getMessage()); } finally { ois.close(); bis.close(); } }
conn = getConnection(); conn.setAutoCommit(false); } catch (IllegalAccessException exc) {
private void reconnection() throws IOException { logger.log(BasicLevel.WARN, "reconnection in progress - starting"); try { if (ds != null) { // conn = ds.getConnection(); closeConnection(); // attempt to close all connection and recreate DataSource. } logger.log(BasicLevel.WARN, "reconnection in progress - old connection closed"); conn = getConnection(); logger.log(BasicLevel.WARN, "reconnection in progress - getConnection success"); conn.setAutoCommit(false); insertStmt = conn.prepareStatement("INSERT INTO JoramDB VALUES (?, ?)"); updateStmt = conn.prepareStatement("UPDATE JoramDB SET content=? WHERE name=?"); deleteStmt = conn.prepareStatement("DELETE FROM JoramDB WHERE name=?"); } catch (Exception sqle) { sqle.printStackTrace(); throw new IOException(sqle.getMessage()); } logger.log(BasicLevel.WARN, "Database reconnection success"); } }
if (sqle instanceof com.mysql.jdbc.CommunicationsException && !reconnectLoop) { logger.log(BasicLevel.WARN, "Database reconnection problem at list, Reconnecting"); reconnection(); reconnectLoop = true; String[] result = list(prefix); reconnectLoop = false; return result;
reconnection(); reconnectLoop = true; delete(dirName, name); reconnectLoop = false; } else {