/** @see java.sql.Statement#executeQuery(java.lang.String) */ public ResultSet getAnotherResultSet() throws SQLException { logger.debug("Redo st.executeQuery and get ResultSet.\n" + sql); // resultSet内で障害を検知したので、再度コネクションを張り直す。 con.notifyError(this); // エラーを通知。ここでstは新しいものになっているはず。 ResultSet rs = st.executeQuery(sql); return rs; }
/** * クラスタリング対応のメソッド実行処理。 * * @param methodName * @param args * @return * @throws SQLException */ private Object clusterCall( String methodName, Object[] args, Class<?>[] parameterTypes, boolean saveMethod) throws SQLException { Object result = null; CalledMethod calledMethod = new CalledMethod(methodName, args, parameterTypes); logger.debug(calledMethod.toString()); try { result = calledMethod.invoke(st); } catch (Exception e) { logger.warn(MSG_WARN_SWITCH_DB, e); // try { st.close(); } catch (SQLException se) {} con.notifyError(this); // エラーを通知。ここでstは新しいものになっているはず。 try { // 再度実行。ここでもさらにエラーがでるならSQLExceptionにラップする。 result = calledMethod.invoke(st); } catch (InvocationTargetException e2) { // 例外がSQLExceptionならそのままthrow Throwable t = e2.getTargetException(); if (t instanceof SQLException) { throw (SQLException) t; } // それ以外ならwrapしてthrow SQLException sqle = new SQLException(); sqle.initCause(e2.getTargetException()); throw sqle; } catch (Exception e2) { SQLException sqle = new SQLException(); sqle.initCause(e2); throw sqle; } } if (saveMethod) { methodList.add(calledMethod); } return result; }