A stored procedure is a group of SQL statements that form a logical unit and perform a particular task, and they are used to encapsulate a set of operations or queries to execute on a database server.

String createProcedure = "create procedure SHOW_SUPPLIERS " +
			 "as " +
			 "from SUPPLIERS, COFFEES " +
			 "order by SUP_NAME";

The following code fragment uses the Connection object con to create a Statement object, which is used to send the SQL statement creating the stored procedure to the database:

Statement stmt = con.createStatement();

JDBC allows you to call a database stored procedure from an application written in the Java programming language.

CallableStatement cs = con.prepareCall("{call SHOW_SUPPLIERS}");
ResultSet rs = cs.executeQuery();