Steve
Steve

Reputation: 4681

Spring Integration JDBC Insert Statement

I'm new to Spring integration. I'm trying to write a POJO for my database. I'm getting this error, which I don't quite understand. Is my syntax wrong, or am I using channels/adapters/gateways in the wrong manner?

no declaration can be found for element int-jdbc:outbound-channel-adapter.

Here is my code:

 <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:integration="http://www.springframework.org/schema/integration"
    xmlns:file="http://www.springframework.org/schema/integration/file"
    xmlns:int-jdbc="http://www.springframework.org/schema/integration/jdbc"
    xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
    xmlns:util="http://www.springframework.org/schema/util" xmlns:int-ftp="http://www.springframework.org/schema/integration/ftp"
    xsi:schemaLocation="http://www.springframework.org/schema/integration/jdbc http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
        http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
        http://www.springframework.org/schema/integration/ftp http://www.springframework.org/schema/integration/ftp/spring-integration-ftp.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">


<int-jdbc:outbound-gateway id="transmissionGateway"
    query="insert into MSRB_RTRS (Sec_ID, SourceLoad_ID, TradeDate) values (:Sec_ID, 
    :SourceLoad_ID, :TradeDate)"
    data-source="rmsa">

</int-jdbc:outbound-gateway>

public interface DatabaseService {
    public void insertMessage(int secID, int sourceLoadID, String tradeDate);
}

@Inject
DatabaseService service;

service.insertMessage(-1, -1, "20170830");

Here are my dependencies:

<dependencies>
    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-jdbc</artifactId>
        <version>4.3.5.RELEASE</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>com.microsoft.sqlserver</groupId>
        <artifactId>mssql-jdbc</artifactId>
        <version>6.0.8112.100</version>
    </dependency>
    <dependency>
        <groupId>com.companyname</groupId>
        <artifactId>spring-boot-common</artifactId>
        <version>1.0.0.COMMON-SBCOMMON-14</version>
    </dependency>
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.13</version>
    </dependency>


    <!-- End -->
    <dependency>
        <groupId>com.companyname</groupId>
        <artifactId>companyname-spring-core-spring-4</artifactId>
        <version>1.1-M20160505-01</version>
    </dependency>
    <dependency>
        <groupId>commons-httpclient</groupId>
        <artifactId>commons-httpclient</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.5</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>

The spring integration jdbc pom contains

  <dependency>
      <groupId>org.springframework.integration</groupId>
      <artifactId>spring-integration-core</artifactId>
      <version>4.3.5.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>4.3.4.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>19.0</version>
      <scope>compile</scope>
      <optional>true</optional>
    </dependency>

Upvotes: 0

Views: 498

Answers (1)

Gary Russell
Gary Russell

Reputation: 174534

spring-integration-jdbc-2.2.xsd

Don't put a version on the schema import. It has to match the version you are using (4.3).

If you leave the version off, Spring will resolve the right version for you (see /META-INF/spring.schemas in the jar).

http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc.xsd

In any case; everything (jars, schema) must have matching versions.

Upvotes: 1

Related Questions