1 22 23 package org.continuent.sequoia.common.exceptions; 24 25 import java.sql.SQLException ; 26 import java.util.Iterator ; 27 import java.util.List ; 28 29 35 public class SQLExceptionFactory 36 { 37 38 45 public static SQLException getSQLException(SQLException sqlEx, 46 String sequoiaMessage) 47 { 48 SQLException newException = new SQLException (sequoiaMessage, sqlEx 49 .getSQLState(), sqlEx.getErrorCode()); 50 newException.setNextException(sqlEx); 55 return newException; 56 } 57 58 67 public static SQLException getSQLException(List exceptions, 68 String sequoiaMessage) 69 { 70 String sqlState = null; 71 int errorCode = 0; 72 for (int i = 0; i < exceptions.size(); i++) 73 { 74 SQLException ex = (SQLException ) exceptions.get(i); 75 if (ex == null) 76 continue; 77 sequoiaMessage += ex.getMessage() + "\n"; 78 if (sqlState == null) 79 { 80 sqlState = ex.getSQLState(); 82 errorCode = ex.getErrorCode(); 83 } 84 } 88 SQLException newHead = new SQLException (sequoiaMessage, sqlState, errorCode); 89 Iterator exIter = exceptions.iterator(); 90 91 while (exIter.hasNext()) 94 newHead.setNextException((SQLException ) exIter.next()); 95 96 return newHead; 97 } 98 99 } 100 | Popular Tags |