public class InvalidSQlException extends SQLException
{
InvalidSQLException(SQLException ex)
{
super(ex.getMessage(), ex.getSQLState(), ex.getErrorCode());
}
}
public class SQLExceptionaspect
{
public Object handleSqlException(Invocation invocation) throws Throwable
{
try
{
return invocation.invokeNext();
}
catch (SQLException ex)
{
if (isVendorInvalidSqlErrorCode(ex.getErrorCode())) throw new InvalidSQLException(ex);
if (isVendorDeadlockErrorCode(ex.getErrorCode()) throw new SQLDeadlockException(ex);
... and so on ...
}
}
... impl of isVendor methods ...
}
<aspect class="SQLExceptionAspect" scope="PER_VM"/>进入讨论组讨论。
<bind pointcut="call(* $instanceof{java.sql.Statement}->execute*(..))">
<advice name="handleSqlException" aspect="SQLExceptionAspect"/>
</bind>
(出处:http://www.VeVb.com)
新闻热点
疑难解答