1 16 package com.ibatis.common.jdbc.exception; 17 18 import com.ibatis.common.exception.NestedRuntimeException; 19 20 import java.sql.SQLException ; 21 22 25 public class RuntimeSQLException extends NestedRuntimeException { 26 27 30 public RuntimeSQLException() { 31 } 32 33 38 public RuntimeSQLException(String msg) { 39 super(msg); 40 } 41 42 47 public RuntimeSQLException(SQLException sqlException) { 48 super(sqlException); 49 } 50 51 57 public RuntimeSQLException(String msg, SQLException sqlException) { 58 super(msg, sqlException); 59 } 60 61 65 public String getSQLState() { 66 Throwable cause = getCause(); 67 if (cause instanceof SQLException ) { 68 return ((SQLException ) cause).getSQLState(); 69 } else { 70 return null; 71 } 72 73 } 74 75 79 public int getErrorCode() { 80 Throwable cause = getCause(); 81 if (cause instanceof SQLException ) { 82 return ((SQLException ) cause).getErrorCode(); 83 } else { 84 return -1; 85 } 86 } 87 88 92 public SQLException getNextException() { 93 Throwable cause = getCause(); 94 if (cause instanceof SQLException ) { 95 return ((SQLException ) cause).getNextException(); 96 } else { 97 return null; 98 } 99 } 100 101 105 public synchronized void setNextException(SQLException ex) { 106 Throwable cause = getCause(); 107 if (cause instanceof SQLException ) { 108 ((SQLException ) cause).setNextException(ex); 109 } 110 } 111 112 } 113 | Popular Tags |