One reason to write a stored procedure is that Java does not return values in primitive arguments (simple integers, etc.) whereas stored procedures allow OUT and INOUT parameters. With Java you can modify a field encapsulated within an object parameter, and the wrapper sp can hide the details. In this example DemoProcArg is a Java class created for the sole purpose of returning an integer value as a parameter.