plication written for one driver vendor may get a different result-field object if you run it against the same tables using drivers from another vendor. "Because the spec is loose, so are the implementations," Mullins complains.
3. Control the Use of "Undefined" Fields.
JDBC driver vendors may choose not to support a given database type and describe it as an "undefined" field when one or more of the JDBC types could readily be used to map the value into JDBC. "This is often done because it makes passing the JDBC driver compatibility tests easie
r," Mullins says. "Those tests allow database types to be listed as 'undefined', and doing so will skip any logic that might test their compatibility."
4. Standardize Metadata Management.
To create a JDBC command as one line of code that works under a variety of JDBC drivers requires custom coding for developers to achieve consistent results.
Mullins offers a hypothetical example: To find all the columns for a given table, a call passes through the fields "catalog" (the database catalog name), "schemaPattern" (the user ID in Oracle and other DBMSes), "tablePattern" (a table or wildcard pattern used for tables), and "columnNamePattern" (the column name or wildcard).
"The values I enter for these for fields will vary wildly among JDBC drivers," Mullins says. "Some want the catalog parameter to be an empty string. Others want it to be a 'null' value. Others want it to be a wildcard (usually a % character as a Java string). Likewise the schema, table, and column patterns can vary in the same w
ay."
Mullins says there are also problems with the return values of getColumns in many drivers. "Some throw in Java exceptions when you try to extract the results, which must be caught correctly or your whole program blows up," he says. "Others return faulty data, such as invalid column data-type information, while others simply don't return certain information that should be readily available."
5. Handle Transactions Consistently.
Some JDBC drivers allow only one result set, rather than multiple results, open at once. With other drivers, there's a lack of reverse scrollability (i.e., an application can move either forward or backward from the current row).
Finally, some drivers display exceptions if you read the same column twice, and most don't fully support the JDBC matrix of casting. "The casting chart means, for example, I should be able to read an integer value from the database into a Java LONG," Mullins says.