To retrieve a description of the foreign key columns that reference the given table’s primary key columns (the foreign keys exported by a table), you can use the DatabaseMetaData. getExportedKeys() method. This method returns its result as a ResultSet object (which is not very useful for web-based applications). For web-based applications, it is better to return the result as HTML or XML.
The signature of DatabaseMetaData’s .getExportedKeys() is as follows:
This method retrieves a description of the foreign key columns that reference the given table’s primary key columns (the foreign keys exported by a table). They are ordered by FKTABLE_CAT, FKTABLE_SCHEM, FKTABLE_NAME, and KEY_SEQ. Each foreign key column description has the columns shown in Table 9-2.
Table : ResultSet Columns for getExportedKeys()
The parameters are
Oracle Database Setup
Let’s create two tables (dept_table and emp_table) and define the PK and FK. Also, keep in mind that that if you violate the PK and FK rules, the SQL INSERT operation will fail.
MySQL Database Setup
Database changed
The Solution
Invoking GetExportedKeys for MySQL
Figure : shows how to run the solution for the MySQL database.
Invoking GetExportedKeys for Oracle
Figure : shows how to run the solution for the Oracle database.
JDBC Related Interview Questions |
|
---|---|
Core Java Interview Questions | JSP Interview Questions |
Java Servlets Interview Questions | EJB(Enterprise JavaBeans) Interview Questions |
JSTL(JSP Standard Tag Library) Interview Questions | JNDI (Java Naming and Directory Interface) Interview Questions |
Java Bean Utils Interview Questions | AWT (Abstract Window Toolkit) Interview Questions |
Jdbc Tutorial
What Is Jdbc Programming?
Database Metadata, Part 1
Database Metadata, Part 2
Resultset Metadata
Parameter Metadata
Exploring Driver Property Information
Rowset Metadata A
Web Access To Metadata,part 1
Web Access To Metadata, Part 2
Rdf And Jdbc Metadata
Text Resumes
Visual Resumes
Social Resumes
Resume Quality
IT Resume Samples
MARKETING Resume Samples
HR Resume Samples
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.