### Question:
SqlExceptionUtil { public static SQLException create(String message, Throwable cause) { SQLException sqlException; if (cause instanceof SQLException) { sqlException = new SQLException(message, ((SQLException) cause).getSQLState()); } else { sqlException = new SQLException(message); } sqlException.initCause(cause); return sqlException; } private  SqlExceptionUtil(); static SQLException create(String message, Throwable cause);  }### Answer:
@Test public void testException() { Throwable cause = new Throwable(); String msg = "hello"; SQLException e = SqlExceptionUtil.create(msg, cause); assertEquals(msg, e.getMessage()); assertEquals(cause, e.getCause()); }
@Test public void testExceptionWithSQLException() { String sqlReason = "sql exception message"; String sqlState = "sql exception state"; Throwable cause = new SQLException(sqlReason, sqlState); String msg = "hello"; SQLException e = SqlExceptionUtil.create(msg, cause); assertEquals(msg, e.getMessage()); assertEquals(sqlState, e.getSQLState()); assertEquals(cause, e.getCause()); }