Java Reference
In-Depth Information
fire() iscalledwiththeintegeridentifieroftheemployeetofire.Itfirstaccesses
the current Connection object by invoking getConnection() with the jd-
bc.default:connection argument,whichissupportedbyOracleJVMsthrough
a special internal driver.
AftercreatinganSQL UPDATE statementstringtosetthe FIRED columntotruein
the EMPLOYEES tablerowwhereitsIDfieldequalsthevaluein id , fired() invokes
executeUpdate() to update the table appropriately.
Compile Listing 9-18 ( javac EmployeeDB.java ) and run this application
( java EmployeeDB ). You should observe the following output:
1 John Doe false
2 Sally Smith false
1 John Doe false
2 Sally Smith true
Metadata
Adatasourceistypicallyassociatedwith metadata (dataaboutdata)thatdescribesthe
datasource.WhenthedatasourceisanRDBMS,thisdataistypicallystoredinacol-
lection of tables.
Metadata includes a list of catalogs (RDBMS databases whose tables describe
RDBMSobjectssuchas base tables [tablesthatphysicallyexist], views [virtualtables],
and indexes [files that improve the speed of data retrieval operations]), schemas
(namespaces that partition database objects), and additional information (e.g., version
numbers, identifications strings, and limits).
Toaccess a data source's metadata, invoke Connection 's DatabaseMetaData
getMetaData() method. This method returns an implementation instance of the
java.sql.DatabaseMetaData interface.
I'vecreateda MetaData applicationthatdemonstrates getMetaData() andvari-
ous DatabaseMetaData methods. Listing 9-19 presents MetaData 's source code.
Listing 9-19. Obtaining metadata from an employee data source
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
Search WWH ::




Custom Search