I am studying for Java 8 OCP (mainly Exam 1Z0-809). Now I have some confusion about JDBC in Java 8. In detail, I am confused about the createStatement(int resultSetType, int resultSetConcurrency) method of the Connection class.
The OCP book states that, when the specified ResultSet type and ResultSet concurrency mode are not supported, they may be downgraded. So, for example, if I specify ResultSet.TYPE_SCROLL_SENSITIVE for resultSetType, then I may get a Statement whose type is ResultSet.TYPE_SCROLL_INSENSITIVE.
First, welcome to the ranch ! Official documentation says that a SQLException is thrown whenever you try to invoke createStatement on a closed connection or you pass some int values that are not valid result set or cursor types ( i.e, you pass a resultset scroll type value as a resultset concurrency value, misplacing the parameters ); a SqlFeatureNotSupported exception if the required concurrency/scrolling policy aren't supported.Indeed, no mention of downgrading concurrency. I wonder if downgrading or not is implicitly left upon driver's and database's capabilities, even if I think it would be a unreliable behavior - at the end you're never sure about the real concurrency/scrolling type.
I'm pretty curious, let's add some flagsto your question and lt see if someone here can help.
oracle.com wrote:When the DB2 driver cannot support the requested result set type or concurrency, it automatically downgrades the cursor and generates one or more SQLWarnings with detailed information.
For the Java 8 OCP exam, you need to know that even if the code returns a Connection, it doesn't necessarily support the requested behavior.
For the Java 11 OCP exam, these flags aren't tested at all. (Whoo hoo!)