Jump to content

Java stored procedure

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by RedWolf (talk | contribs) at 18:32, 18 May 2006 (wording). 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 the Java programming language, grouped together as an executable unit.

A stored procedure is a program that is kept and executed within a database server. The procedure is called 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.

Since stored procedures run in the DBMS itself, they can help to reduce latency in applications. Rather than executing four or five SQL statements in a Java application, executing one stored procedure performs all the operations on the server side. Reducing the number of network trips alone can have a dramatic effect on performance.