![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]()
(chat, newsreader, calendar)
|
![]() |
|
Course Notes Table of Contents | Exercises JDBC Short Course Index | Online Training Index
|
Help: SQL Warning/Exception Handling |
Working Applet | Help Solution
|
Help is available for each task, or you can go straight to the
source code, which is one particular
solution.
The exception to check for is SQLException
The methods you need to know about are getErrorCode, getSQLState
and getMessage.
The printSQLWarnings method is needed for the rest of the code. It is your job to create it. This method accepts one parameter of a SQLWarning. For each SQLWarning in the chain, print out all the available information about the warning. If the SQLWarning happens to be a DataTruncation warning, display information about that, too. Call printSQLWarnings to print out any warning messages for every time you use a Connection, ResultSet, or Statement.
The getNextWarning() allows you to loop through all the warnings. Also, use instanceof to check for DataTruncation warnings. Task 5Using the DatabaseMetaData, determine the level of ANSI92 SQL supported by the database and the SQL grammar level supported by the ODBC driver.
The supportsANSI92FullSQL, supportsANSI92IntermediateSQL, and
supportsANSI92EntryLevelSQL methods report the ANSI92 SQL level. While,
supportsExtendedSQLGrammar, supportsCoreSQLGrammar, and
supportsMinimumSQLGrammar report the grammar level.
Task 7Close everything.
|
Copyright © 1997 MageLang Institute. All Rights Reserved May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved |