Java – when to call getwarnings() on connections, statements, and resultset using JDBC?

In JDBC, connection, statement and resultset types all have getwarnings () method, which is specified to generate the first warning associated with the object of this type The second and subsequent warnings (if present) will be linked to the first warning (if it even exists, null will be generated if there is no warning)

The specification states that warnings related to these types of objects are cleared after some operations For example, when each new row is read, the warning on the resultset is cleared

Sqlwarning type is a subtype of sqlexception So, does the exception have a warning? If the runtime type of the exception is sqlwarning, the exception will be linked to the associated object?

What I want to know is this. It may be driver specific. How do I know when to call getwarnings () and expect a non null response? In other words, is there a warning on the JDBC object that can only be used after the object throws an exception? (the exception is a warning?)

If my goal is to observe each warning, should I call getWarnings () after each JDBC operation to find the warning "just to confirm"?

Solution

[reference]

Frankly, I never found myself checking warnings Maybe I've never done anything serious

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>