Apache camel Apache Camel sql组件无法转换为内部表示

Apache camel Apache Camel sql组件无法转换为内部表示,apache-camel,camel-sql,Apache Camel,Camel Sql,当我使用sqlcompent从数据库检索记录时,Map是可以的 <to uri="sql-clsivtrk:{{clsiv_tracker_config_se}}?outputType=SelectOne" /> 我得到了错误java.sql.SQLException:无法转换为内部表示形式 Message History --------------------------------------------------------------------------------

当我使用
sqlcompent
从数据库检索记录时,
Map
是可以的

<to uri="sql-clsivtrk:{{clsiv_tracker_config_se}}?outputType=SelectOne" />
我得到了错误
java.sql.SQLException:无法转换为内部表示形式

Message History
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route9            ] [route9            ] [servlet:/events/config?httpMethodRestrict=PUT                                 ] [        93]
[route9            ] [to39              ] [direct:save-config                                                            ] [         0]
[tracker-configurat] [convertBodyTo4    ] [convertBodyTo[java.lang.String]                                               ] [         0]
[tracker-configurat] [unmarshal4        ] [unmarshal[ref:trackerConfigJsonList]                                          ] [         2]
[tracker-configurat] [log4              ] [log                                                                           ] [         1]
[tracker-configurat] [split3            ] [split[simple{${body}}]                                                        ] [         6]
[tracker-configurat] [to6               ] [sql-tracker:{{tracker_config_se}}?outputType=SelectOne&outputClass=br.com.acme] [        83]
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException; SQL state [99999]; error code [17059]; Fail to convert to internal representation; nested exception is java.sql.SQLException: Fail to convert to internal representation
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:89)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
    at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1402)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:620)
    at org.apache.camel.component.sql.SqlProducer.process(SqlProducer.java:116)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:148)
Caused by: java.sql.SQLException: Fail to convert to internal representation
    at oracle.jdbc.driver.CharCommonAccessor.getBoolean(CharCommonAccessor.java:185)
    at oracle.jdbc.driver.T4CVarcharAccessor.getBoolean(T4CVarcharAccessor.java:794)
    at oracle.jdbc.driver.OracleResultSetImpl.getBoolean(OracleResultSetImpl.java:640)
    at com.sun.gjc.spi.base.ResultSetWrapper.getBoolean(ResultSetWrapper.java:169)
    at org.springframework.jdbc.support.JdbcUtils.getResultSetValue(JdbcUtils.java:148)
    at org.springframework.jdbc.core.BeanPropertyRowMapper.getColumnValue(BeanPropertyRowMapper.java:377)
    at org.springframework.jdbc.core.BeanPropertyRowMapper.mapRow(BeanPropertyRowMapper.java:298)
    at org.springframework.jdbc.core.RowMapperResultSetExtractor.extractData(RowMapperResultSetExtractor.java:93)
    at org.apache.camel.component.sql.DefaultSqlEndpoint.queryForObject(DefaultSqlEndpoint.java:488)
    at org.apache.camel.component.sql]]
我的
输出类型

import java.util.Calendar;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;


import java.util.Calendar;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;

public class TrackerConfig
{
    private static final String HOST1                   = "http://locahost/";
    private static final String HOST2                   = "http://localhost/";
    private static final String CONTEXT                 = "my-ctx/";
    private static final String API                     = "api/";

    private static final int    DEFAULT_INTERVAL_TRANSM = 60;
    private static final int    DEFAUL_INTERVAL_CAPT    = 30;
    private static final int    DEFAUL_BATCHSIZE        = 100;
    private static final int    DEFAUL_RENEW_CONF       = 3600;

    private String              deviceImei1;
    private String              deviceImei2;
    private String              phoneNumber;
    private String              deviceSO;
    private String              deviceModel;
    private String              deviceSNumber;
    private String              myIp;

    private String              host1;
    private String              host2;
    private String              context;
    private String              api;

    private Number              intervalOftransmission;
    private Number              intervalOfCapture;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                captureBegin;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                captureFinal;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                transmissionBegin;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                transmissionFinal;
    private Double              minDistance;
    private Double              maxDistance;
    private Number              intervalOfRenewConfig;
    private String              levelConfig;

    private String              deprecated;
    private String              route;
    private String              version;
    private Double              accuracy;
    private Number              batchSize;

    public TrackerConfig()
    {
        this.intervalOftransmission = DEFAULT_INTERVAL_TRANSM;
        this.intervalOfCapture = DEFAUL_INTERVAL_CAPT;
        this.batchSize = DEFAUL_BATCHSIZE;
        this.intervalOfRenewConfig = DEFAUL_RENEW_CONF;
        this.captureBegin = newTime(7, 0, 0);
        this.captureFinal = newTime(18, 0, 0);
        this.transmissionBegin = newTime(4, 6, 0);
        this.transmissionFinal = newTime(23, 59, 59);
        this.minDistance = 10D;
        this.maxDistance = 10001D;
        this.host1 = HOST1;
        this.host2 = HOST2;
        this.context = CONTEXT;
        this.api = API;
        this.levelConfig = "INFO";
    }
    // ommit getters and setters
}

使用
2.22.2

可以显示您的
输出类吗

outputType
下,它指出:

使消费者或生产者的输出选择列表作为地图列表, 或者按以下方式选择一个作为单个Java对象:a)如果 查询只有一列,那么JDBC列对象是 返回。(例如,从PROJECT中选择COUNT()将返回一个长 b)如果查询有多个列,那么它将返回 这一结果的地图。c) 如果设置了outputClass,则它将 通过调用所有 与列名匹配的setter。它将假定您的类具有 用于创建实例的默认构造函数。d) 如果查询结果为 在多行中,它抛出一个非唯一的结果异常


应该做的事情之一是列名应该与setter匹配,并且应该存在默认构造函数。是这样吗?

@Alisson Gomes,这个解决方案足够吗?你能在这种情况下把它标记为已回答吗?不,这个问题是连续的。。。我用

import java.util.Calendar;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;


import java.util.Calendar;
import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;

public class TrackerConfig
{
    private static final String HOST1                   = "http://locahost/";
    private static final String HOST2                   = "http://localhost/";
    private static final String CONTEXT                 = "my-ctx/";
    private static final String API                     = "api/";

    private static final int    DEFAULT_INTERVAL_TRANSM = 60;
    private static final int    DEFAUL_INTERVAL_CAPT    = 30;
    private static final int    DEFAUL_BATCHSIZE        = 100;
    private static final int    DEFAUL_RENEW_CONF       = 3600;

    private String              deviceImei1;
    private String              deviceImei2;
    private String              phoneNumber;
    private String              deviceSO;
    private String              deviceModel;
    private String              deviceSNumber;
    private String              myIp;

    private String              host1;
    private String              host2;
    private String              context;
    private String              api;

    private Number              intervalOftransmission;
    private Number              intervalOfCapture;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                captureBegin;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                captureFinal;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                transmissionBegin;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
    private Date                transmissionFinal;
    private Double              minDistance;
    private Double              maxDistance;
    private Number              intervalOfRenewConfig;
    private String              levelConfig;

    private String              deprecated;
    private String              route;
    private String              version;
    private Double              accuracy;
    private Number              batchSize;

    public TrackerConfig()
    {
        this.intervalOftransmission = DEFAULT_INTERVAL_TRANSM;
        this.intervalOfCapture = DEFAUL_INTERVAL_CAPT;
        this.batchSize = DEFAUL_BATCHSIZE;
        this.intervalOfRenewConfig = DEFAUL_RENEW_CONF;
        this.captureBegin = newTime(7, 0, 0);
        this.captureFinal = newTime(18, 0, 0);
        this.transmissionBegin = newTime(4, 6, 0);
        this.transmissionFinal = newTime(23, 59, 59);
        this.minDistance = 10D;
        this.maxDistance = 10001D;
        this.host1 = HOST1;
        this.host2 = HOST2;
        this.context = CONTEXT;
        this.api = API;
        this.levelConfig = "INFO";
    }
    // ommit getters and setters
}