The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.sql  [73 examples] > Retrieving Data  [7 examples]

e253. Determining If a Fetched Value Is NULL

When a ResultSet.getXXX() method encounters a NULL in the database, it will convert it to a default value. For example, if NULL was encountered in a NUMBER field, ResultSet.getInt() will return 0. In order to determine whether or not the actual value is a NULL, wasNull() must be called. This method must be called immediately after the value is fetched from the result set.
    
    // Fetch each row from the result set
    while (resultSet.next()) {

 Related Examples
e251. Getting Rows from a Database Table
e252. Getting Data from a Result Set
e254. Getting the Column Names in a Result Set
e255. Getting the Number of Rows in a Database Table
e256. Getting BLOB Data from a Database Table
e257. Matching with Wildcards in a SQL Statement

See also: Batching    Connections    Database Meta Data    Deleting Data    Drivers    Importing and Exporting    Inserting and Updating Data    Oracle OBJECTs    Oracle VARRAYs    Procedures and Functions    Scrollable Result Sets    Tables    Updatable Result Sets   


© 2002 Addison-Wesley.