Вопрос

I want make a Type

try {
    stmt.execute("CREATE OR REPLACE TYPE angestellte_t UNDER person_t (Name VARCHAR(20))");
}
catch (SQLException e) {
    e.printStackTrace();
}

the Type under_t is not exist and SQLException is not called, but the type is created after this command in database and it shows (in database), that there are errors.

Can i see the errors while compiling in java?
Why it does not show SQLException?

Thanks

Это было полезно?

Решение

Creating PL/SQL objects doesn't throw an exception, the only indication that something went wrong is available through the warnings on the statement object.

So, after you run the DDL, use stmt.getWarnings() to see if there were any warnings. If getWarnings() returns something else than null, then something went wrong.

This corresponds to the message "Warning: Type created with compilation errors" that you would have gotten in SQL*Plus (if you call SQLWarning.getMessage() you actually get a similar message).

If there was a warning then the only way to retrieve the real error message is to query the view ALL_ERRORS in your case you must run:

select line, position, text
from all_errors
where type = 'TYPE'
and name = 'ANGESTELLTE_T'
order by line;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top