Files
spring-integration-samples/intermediate/stored-procedures-postgresql
Spring Operator fce2acb3fa URL Cleanup
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener).

# Fixed URLs

## Fixed But Review Recommended
These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended.

* http://services.gradle.org/distributions/gradle- (404) with 1 occurrences migrated to:
  https://services.gradle.org/distributions/gradle- ([https](https://services.gradle.org/distributions/gradle-) result 404).

## Fixed Success
These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended.

* http://maven.apache.org/xsd/maven-4.0.0.xsd with 63 occurrences migrated to:
  https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200).
* http://www.apache.org/licenses/LICENSE-2.0 with 4 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200).
* http://www.apache.org/licenses/LICENSE-2.0.txt with 64 occurrences migrated to:
  https://www.apache.org/licenses/LICENSE-2.0.txt ([https](https://www.apache.org/licenses/LICENSE-2.0.txt) result 200).
* http://projects.spring.io/spring-integration with 64 occurrences migrated to:
  https://projects.spring.io/spring-integration ([https](https://projects.spring.io/spring-integration) result 301).
* http://repo.spring.io/libs-milestone with 2 occurrences migrated to:
  https://repo.spring.io/libs-milestone ([https](https://repo.spring.io/libs-milestone) result 302).
* http://repo.spring.io/libs-snapshot with 2 occurrences migrated to:
  https://repo.spring.io/libs-snapshot ([https](https://repo.spring.io/libs-snapshot) result 302).
* http://repo.spring.io/libs-staging-local with 1 occurrences migrated to:
  https://repo.spring.io/libs-staging-local ([https](https://repo.spring.io/libs-staging-local) result 302).

# Ignored
These URLs were intentionally ignored.

* http://maven.apache.org/POM/4.0.0 with 126 occurrences
* http://www.w3.org/2001/XMLSchema-instance with 63 occurrences
2019-03-16 12:52:58 -04:00
..
2019-03-16 12:52:58 -04:00

Spring Integration - Stored Procedure Example - PostgreSQL

Overview

This example provides a simple example using the Stored Procedure Outbound Gateway adapter. This example will call 1 PostgreSQL Stored Function and 1 Stored Procedure.

The second procedure returns a ResultSet.

Setup

PostgreSQL

Please ensure that you can connect to a running instance of a PostgreSQL server. The sample was tested using PostgreSQL v9.2.1.

Required Table

CREATE TABLE "COFFEE_BEVERAGES"
(
  "ID" integer NOT NULL,
  "COFFEE_NAME" text,
  "COFFEE_DESCRIPTION" text,
  CONSTRAINT "COFFEE_BEVERAGES_pkey" PRIMARY KEY ("ID")
)

Sample Data

INSERT INTO "COFFEE_BEVERAGES" ("ID", "COFFEE_NAME", "COFFEE_DESCRIPTION") VALUES (1, 'Espresso',     'Espressos keep developers going in the morning. There are never enough of them.');
INSERT INTO "COFFEE_BEVERAGES" ("ID", "COFFEE_NAME", "COFFEE_DESCRIPTION") VALUES (2, 'Cappuccino',   'For the finer moments. Wrap your espresso in a tasty layer of foam.');
INSERT INTO "COFFEE_BEVERAGES" ("ID", "COFFEE_NAME", "COFFEE_DESCRIPTION") VALUES (3, 'Mocha',        'Mmmmh, chocolate.');
INSERT INTO "COFFEE_BEVERAGES" ("ID", "COFFEE_NAME", "COFFEE_DESCRIPTION") VALUES (4, 'Latte',        'If you are more into milk than into foam.');

Stored Procedures

Please create the following Stored Procedure/Function:

CREATE OR REPLACE FUNCTION find_all_coffee_beverages()
  RETURNS refcursor AS
$BODY$
DECLARE
    ref refcursor;
BEGIN
  OPEN ref FOR SELECT "ID", "COFFEE_NAME", "COFFEE_DESCRIPTION" FROM "COFFEE_BEVERAGES";
  RETURN ref;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
CREATE OR REPLACE FUNCTION find_coffee(coffee_name integer)
  RETURNS character varying AS
$BODY$
declare
    description character varying;
begin
    SELECT into description "COFFEE_DESCRIPTION" from "COFFEE_BEVERAGES" where "ID"=coffee_name;
    return description;
end
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;

Configure the DataSource

Please configure the necessary credentials in order to connect to your database in /src/main/resources/META-INF/spring/integration/spring-integration-context.xml. The default setting expects a database integration to run on localhost with a usersname of postgres and a password of postgres.

Run the Sample

  • running the "Main" class from within STS (Right-click on Main class --> Run As --> Java Application)

  • or from the command line:

    $ gradlew :stored-procedures-postgresql:run

  • Follow the screen (command line) instructions.


For help please take a look at the Spring Integration documentation:

http://www.springsource.org/spring-integration