What is a “stored procedure”? A stored procedure or function is a program running in the database server that can take actions based on the input parameters. A stored procedure can have input, output, and input/output parameters. In JDBC, you may use a CallableStatement to invoke a stored procedure. Since CallableStatement extends PreparedStatement, you can invoke CallableStatement.getParameterMetaData() to get metadata information on a stored procedure’s parameters. In general, using a stored procedure is faster than doing the same work on a client, because the program runs right inside the database server. Stored procedures are normally written in SQL, Java, or combination of other languages such as PL/SQL (in Oracle).
According toWikipedia, a stored procedure is “a program (or procedure) which is physically stored within a database. They are usually written in a proprietary database language like PL/SQL for Oracle database. The advantage of a stored procedure is that when it is run, in response to a user request, it is run directly by the database engine, which usually runs on a separate database server. As such, it has direct access to the data it needs to manipulate and only needs to send its results back to the user.”
Next, let’s set up a stored procedure (called proc3), and invoke it using a CallableStatement. Then, we’ll invoke CallableStatement.getParameterMetaData() to get the stored procedure’s parameters metadata.
First, define a stored procedure in Oracle that has three parameters:
$ sqlplus scott/tigerNow, we can check to see if a CallableStatement supports ParameterMetaData:
//If you add these lines to the CallProc3 class
(call the new class CallProc3WithMetadata) and run the program again, you will get the following error (this means that Oracle does not support the CallableStatement.getParameterMetaData() method):
There is an alternative way that you can get the metadata information on a stored procedure’s parameters: you can use Connection.getMetaData(), which will give you a DatabaseMetaData object, and then using that DatabaseMetaData object, you can get the signature of all stored procedures by using the following methods:
// retrieves a description of the stored proceduresJDBC 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.