Variables In Jdbc Applications - IBM DB2 Manual

Table of Contents

Advertisement

DatabaseMetaData.getDatabaseProductName returns a string that identifies the
database manager and the operating system. The string has one of the following
formats:
database-productdatabase-product/operating-system
The following table shows examples of values that are returned by
DatabaseMetaData.getDatabaseProductName.
Table 3. Examples of DatabaseMetaData.getDatabaseProductName values
getDatabaseProductName value
DB2
DB2/LINUXX8664
IDS/UNIX64
DatabaseMetaData.getDatabaseVersionName returns a string that contains the
database product indicator and the version number, release number, and
maintenance level of the data source.
The following table shows examples of values that are returned by
DatabaseMetaData.getDatabaseProductVersion.
Table 4. Examples of DatabaseMetaData.getDatabaseProductVersion values
getDatabaseProductVersion value
DSN09015
SQL09010
IFX11100

Variables in JDBC applications

As in any other Java application, when you write JDBC applications, you declare
variables. In Java applications, those variables are known as Java identifiers.
Some of those identifiers have the same function as host variables in other
languages: they hold data that you pass to or retrieve from database tables.
Identifier empNo in the following code holds data that you retrieve from the
EMPNO table column, which has the CHAR data type.
String empNo;
// Execute a query and generate a ResultSet instance
rs = stmt.executeQuery("SELECT EMPNO FROM EMPLOYEE");
while (rs.next()) {
}
Your choice of Java data types can affect performance because DB2 picks better
access paths when the data types of your Java variables map closely to the DB2
data types.
String empNo = rs.getString(1);
System.out.println("Employee number = " + empNo);
Related concepts
"Example of a simple JDBC application" on page 7
Related reference
"Data types that map to database data types in Java applications" on page 193
Database product
DB2 for z/OS
DB2 Database for Linux, UNIX, and Windows on Linux
on x86
IBM Informix Dynamic Server (IDS) on UNIX
Database product version
DB2 for z/OS Version 9.1 in new-function mode
DB2 Database for Linux, UNIX, and Windows Version 9.1
IDS Version 11.10
Chapter 3. JDBC application programming
23

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents