1 23 24 package org.objectweb.cjdbc.common.exceptions.driver.protocol; 25 26 import java.io.IOException ; 27 import java.sql.SQLException ; 28 29 import org.objectweb.cjdbc.common.stream.CJDBCInputStream; 30 31 37 public class BackendDriverException 38 extends SerializableException 39 { 40 43 public BackendDriverException(CJDBCInputStream in) throws IOException 44 { 45 super(in); 46 } 47 48 60 public BackendDriverException(Throwable start) 61 { 62 super(start.getMessage(), convertNext(start)); convertStackTrace(start); 64 65 if (start instanceof SQLException ) { 67 SQLException sqlE = (SQLException ) start; 68 setSQLState(sqlE.getSQLState()); 69 setErrorCode(sqlE.getErrorCode()); 70 } 71 } 72 73 77 78 private static SerializableException convertNext(Throwable regularEx) 79 { 80 84 90 Throwable newStyleCause = regularEx.getCause(); 91 if (null != newStyleCause) 92 return new BackendDriverException(newStyleCause); 93 94 if (regularEx instanceof SQLException ) 96 { 97 SQLException nextE = ((SQLException ) regularEx).getNextException(); 98 if (null != nextE) 99 return new BackendDriverException(nextE); 100 } 101 102 return null; 104 105 } 106 } | Popular Tags |