Package com.adaptris.core.json.jdbc
Class JdbcJsonOutput
java.lang.Object
com.adaptris.core.services.jdbc.ResultSetTranslatorBase
com.adaptris.core.services.jdbc.StyledResultTranslatorImp
com.adaptris.core.json.jdbc.JdbcJsonOutput
- All Implemented Interfaces:
ComponentLifecycle
,ComponentLifecycleExtension
,ResultSetTranslator
- Direct Known Subclasses:
JdbcJsonArrayOutput
,JdbcJsonOutputLines
@ComponentProfile(summary="Output the first resultset as JSON",
tag="json,jdbc")
public class JdbcJsonOutput
extends StyledResultTranslatorImp
Implementation of
ResultSetTranslator
that outputs the first result set as json.
Takes the first result set and writes out each row as part of a json array. You should use this output implementation if you
are executing a SELECT via JdbcDataQueryService
.
[{ "firstName": "John",
"lastName": "Doe"
},
{
"firstName": "Anna",
"lastName": "Smith"
},
{
"firstName": "Peter",
"lastName": "Jones"
}]
In the adapter configuration file this class is aliased as jdbc-json-first-resultset-output which is the preferred alternative to the fully qualified classname when building your configuration.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.adaptris.core.services.jdbc.StyledResultTranslatorImp
StyledResultTranslatorImp.ColumnStyle
-
Field Summary
Fields inherited from class com.adaptris.core.services.jdbc.ResultSetTranslatorBase
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected JdbcResultSet
firstResultSet
(JdbcResult result) void
translate
(JdbcResult source, AdaptrisMessage target) protected void
writeResultSet
(JdbcResultSet result, com.fasterxml.jackson.core.JsonGenerator generator) Methods inherited from class com.adaptris.core.services.jdbc.StyledResultTranslatorImp
getColumnNameStyle, setColumnNameStyle, withColumnNameStyle
Methods inherited from class com.adaptris.core.services.jdbc.ResultSetTranslatorBase
prepare
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Field Details
-
mapper
protected transient com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Constructor Details
-
JdbcJsonOutput
public JdbcJsonOutput()
-
-
Method Details
-
translate
public void translate(JdbcResult source, AdaptrisMessage target) throws SQLException, ServiceException - Throws:
SQLException
ServiceException
-
writeResultSet
protected void writeResultSet(JdbcResultSet result, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException - Throws:
IOException
-
firstResultSet
-
withColumnStyle
-