Reputation: 1129
When I use sql-compenent
to retrieve records from database as Map<String,Object>
is OK.
<to uri="sql-clsivtrk:{{clsiv_tracker_config_se}}?outputType=SelectOne" />
But, when I define a outputClass
like this:
<to uri="sql-clsivtrk:{{clsiv_tracker_config_se}}?outputType=SelectOne&outputClass=br.com.rwit.clsi.m2m.rs.model.TrackerConfig" />
I got the error java.sql.SQLException: Fail to convert to internal representation
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]]
My outputType
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
}
using 2.22.2
Upvotes: 0
Views: 1494
Reputation: 764
Could you show your outputClass
?
Under outputType
it states:
Make the output of consumer or producer to SelectList as List of Map, or SelectOne as single Java object in the following way: a) If the query has only single column, then that JDBC Column object is returned. (such as SELECT COUNT( ) FROM PROJECT will return a Long object. b) If the query has more than one column, then it will return a Map of that result. c) If the outputClass is set, then it will convert the query result into an Java bean object by calling all the setters that match the column names. It will assume your class has a default constructor to create instance with. d) If the query resulted in more than one rows, it throws an non-unique result exception.
One of the things that should be done is that the column names should match the setters and a default constructor should be present. Is this the case?
Upvotes: 1