Since you were actually asking two questions, I've split it into a separate topic. Next time please
UseOneThreadPerQuestion.
SQL procedures, usually called
stored procedures, are a piece of code stored and executed inside the database. Different databases use different languages for stored procedures, for example MS SQL Server uses Transact-SQL, and Oracle uses PL/SQL. Plain SQL commands and queries can usually be easily embedded into the stored procedure. Stored procedures are part of the database schema. A
Java application would typically call a stored procedure which was created in the database by a setup script, for example. It is possible to create a new stored procedure from Java, but certainly not usual.
JDBC has a special escape sequence for calling a stored procedure, because the exact syntax used to call it may differ among databases.
The most important reason to use a stored procedure is (in my opinion) to move processing to the database, so a to avoid transferring large amounts of data from database to application and back over the network. There are other valid reasons, such as concentrating DB specific features inside stored procedures, so that in case of migration to another database just the stored procedures would have to be ported.
Wikipedia has some more information on stored procedures.