public static void printThrowable(Throwable t, String sql, PrintStream out) {
out.println(sql);
Throwable answer = t;
if (t instanceof TeiidSQLException) {
TeiidSQLException sqle = (TeiidSQLException) t;
SQLException se = sqle.getNextException();
if (se != null) {
SQLException s = null;
while( (s = se.getNextException()) != null) {
se = s;
}