Jump to content

Java stored procedure

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 172.216.140.150 (talk) at 15:34, 14 January 2006 (Reverting (minor) vandalism). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A Java stored procedure is a set of SQL statements, written in Java programming language, grouped together as an executable unit.

A stored procedure is a program that is kept and executed within a database server. You call the procedure from a Java class using a special syntax. When you call it, the name of the procedure and the parameters you specify are sent over the JDBC connection to the DBMS, which executes the procedure and returns the results (if any) back over the connection.

Using stored procedures has a lot of the same advantages as using application servers based on EJBs or CORBA. The difference is that stored procedures come free with lots of popular DBMSs, while application servers are mostly expensive. This isn't just an issue of license cost. The time it takes to administer and write code for app servers, and the increased complexity of the client applications that rely on them, can be almost wholly replaced by a reliance on your DBMS.

Because stored procedures run in the DBMS itself, they can help to reduce latency in applications. Rather than executing four or five SQL statements in your Java code, you just execute one stored procedure that does the operations for you on the server side. Reducing the number of network trips alone can have a dramatic effect on performance.