Retrieving Column Values

Many of the examples up to this point use the getString() method to turn a column value into a Java data type. As one might expect, getString() returns the contents of the column in the result set as a character string. There are a number of these methods, but before discussing the purpose of getX() methods, some understanding of SQL and Java data types is required.

Most SQL data types have a corresponding Java data type, and the following table lists all of the types available in Apache Derby, as well as the corresponding getX() methods associated with their retrieval.

Table 9-4. SQL versus Java Data Types
SQL Data TypeJava.sql.TypesgetX() Method
SMALLINTSMALLINTgetShort()
INTEGERINTEGERgetInt()
BIGINTBIGINTgetLong()
DECIMAL ...

Get Apache Derby—Off to the Races: Includes Details of IBM® Cloudscape™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.