When you’re building SQL adapters and database GUI applications, keep in mind that clients might be interested in viewing and selecting columns (and their associated data types). Before you insert new records into a table, you might want to check the table columns’ associated types. Doing so can prevent redundant network traffic.
You can use DatabaseMetaData.getColumns() to get list of columns for a table or view. In production environments, try to minimize passing null/empty parameter values to this method. Passing non-null and non-empty parameter values to JDBC metadata methods can improve the overall performance of your applications.
getColumnNames()// Oracle requires table names to in uppercase characters // MySQL is case-insensitive to table names
The following test program prints a listing of the column names for the table MyPayrollTable:// // print the list of column names for table MyPayrollTable //
The name and type combination provides information about the table schema, but it is not enough. You need to get other useful information, such as the size of the column and whether the column is nullable. (Nullable means that the column accepts the NULL value; note that NULL in SQL is not a zero or an empty value but instead indicates that the value is missing.) So, you can modify the program to provide more detailed information for each column. Since you are returning four distinct pieces of information for each column, you will return the result as an XML String object. For each column, the following information will be returned:
Testing getColumnDetails()// // print the detail of columns for table TestTable77 //
Output of Testing getColumnDetails()33faf4ff068d72f2adcfa053cf4f7274
getColumnDetails() Method: Selecting Type, Size, Nullable, Position
The following method selects the specific metadata that you are interested in by passing a boolean flag for each metadata:
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|
What Is Jdbc Programming?
Database Metadata, Part 1
Database Metadata, Part 2
Exploring Driver Property Information
Rowset Metadata A
Web Access To Metadata,part 1
Web Access To Metadata, Part 2
Rdf And Jdbc Metadata
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.