Package org.apache.camel.component.jdbc
Class JdbcEndpoint
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.component.jdbc.JdbcEndpoint
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.CamelContextAware
,org.apache.camel.ComponentAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasCamelContext
,org.apache.camel.spi.HasId
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="1.2.0",
scheme="jdbc",
title="JDBC",
syntax="jdbc:dataSourceName",
producerOnly=true,
category=DATABASE,
headersClass=JdbcConstants.class)
public class JdbcEndpoint
extends org.apache.camel.support.DefaultEndpoint
Access databases through SQL and JDBC.
-
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
ConstructorDescriptionJdbcEndpoint
(String endpointUri, org.apache.camel.Component component, DataSource dataSource) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.Consumer
createConsumer
(org.apache.camel.Processor processor) protected String
org.apache.camel.Producer
int
boolean
boolean
boolean
boolean
boolean
boolean
void
setAllowNamedParameters
(boolean allowNamedParameters) Whether to allow using named parameters in the queries.void
setBeanRowMapper
(BeanRowMapper beanRowMapper) To use a custom org.apache.camel.component.jdbc.BeanRowMapper when using outputClass.void
setConnectionStrategy
(ConnectionStrategy connectionStrategy) To use a custom strategy for working with connections.void
setDataSource
(DataSource dataSource) The data source to usevoid
setDataSourceName
(String dataSourceName) Name of DataSource to lookup in the Registry.void
setOutputClass
(String outputClass) Specify the full package and class name to use as conversion when outputType=SelectOne or SelectList.void
setOutputType
(JdbcOutputType outputType) Determines the output the producer should use.void
setParameters
(Map<String, Object> parameters) Optional parameters to theStatement
.void
setPrepareStatementStrategy
(JdbcPrepareStatementStrategy prepareStatementStrategy) Allows the plugin to use a custom org.apache.camel.component.jdbc.JdbcPrepareStatementStrategy to control preparation of the query and prepared statement.void
setReadSize
(int readSize) The default maximum number of rows that can be read by a polling query.void
setResetAutoCommit
(boolean resetAutoCommit) Camel will set the autoCommit on the JDBC connection to be false, commit the change after executed the statement and reset the autoCommit flag of the connection at the end, if the resetAutoCommit is true.void
setTransacted
(boolean transacted) Whether transactions are in use.void
setUseGetBytesForBlob
(boolean useGetBytesForBlob) To read BLOB columns as bytes instead of string data.void
setUseHeadersAsParameters
(boolean useHeadersAsParameters) Set this option to true to use the prepareStatementStrategy with named parameters.void
setUseJDBC4ColumnNameAndLabelSemantics
(boolean useJDBC4ColumnNameAndLabelSemantics) Sets whether to use JDBC 4 or JDBC 3.0 or older semantic when retrieving column name.Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getComponent, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStart, doStop, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.camel.ComponentAware
getComponent
Methods inherited from interface org.apache.camel.Endpoint
getEndpointBaseUri, isSingletonProducer
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Constructor Details
-
JdbcEndpoint
public JdbcEndpoint() -
JdbcEndpoint
public JdbcEndpoint(String endpointUri, org.apache.camel.Component component, DataSource dataSource)
-
-
Method Details
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception - Throws:
Exception
-
createProducer
- Throws:
Exception
-
getDataSourceName
-
setDataSourceName
Name of DataSource to lookup in the Registry. If the name is dataSource or default, then Camel will attempt to lookup a default DataSource from the registry, meaning if there is a only one instance of DataSource found, then this DataSource will be used. -
getReadSize
public int getReadSize() -
setReadSize
public void setReadSize(int readSize) The default maximum number of rows that can be read by a polling query. The default value is 0. -
isTransacted
public boolean isTransacted() -
setTransacted
public void setTransacted(boolean transacted) Whether transactions are in use. -
isResetAutoCommit
public boolean isResetAutoCommit() -
setResetAutoCommit
public void setResetAutoCommit(boolean resetAutoCommit) Camel will set the autoCommit on the JDBC connection to be false, commit the change after executed the statement and reset the autoCommit flag of the connection at the end, if the resetAutoCommit is true. If the JDBC connection doesn't support to reset the autoCommit flag, you can set the resetAutoCommit flag to be false, and Camel will not try to reset the autoCommit flag. When used with XA transactions you most likely need to set it to false so that the transaction manager is in charge of committing this tx. -
getDataSource
-
setDataSource
The data source to use -
getParameters
-
setParameters
Optional parameters to theStatement
. For example to set maxRows, fetchSize etc.- Parameters:
parameters
- parameters which will be set using reflection
-
isUseJDBC4ColumnNameAndLabelSemantics
public boolean isUseJDBC4ColumnNameAndLabelSemantics() -
setUseJDBC4ColumnNameAndLabelSemantics
public void setUseJDBC4ColumnNameAndLabelSemantics(boolean useJDBC4ColumnNameAndLabelSemantics) Sets whether to use JDBC 4 or JDBC 3.0 or older semantic when retrieving column name. JDBC 4.0 uses columnLabel to get the column name where as JDBC 3.0 uses both columnName or columnLabel. Unfortunately JDBC drivers behave differently so you can use this option to work out issues around your JDBC driver if you get problem using this component This option is default true.- Parameters:
useJDBC4ColumnNameAndLabelSemantics
- true to use JDBC 4.0 semantics, false to use JDBC 3.0.
-
getPrepareStatementStrategy
-
setPrepareStatementStrategy
Allows the plugin to use a custom org.apache.camel.component.jdbc.JdbcPrepareStatementStrategy to control preparation of the query and prepared statement. -
isAllowNamedParameters
public boolean isAllowNamedParameters() -
setAllowNamedParameters
public void setAllowNamedParameters(boolean allowNamedParameters) Whether to allow using named parameters in the queries. -
isUseHeadersAsParameters
public boolean isUseHeadersAsParameters() -
setUseHeadersAsParameters
public void setUseHeadersAsParameters(boolean useHeadersAsParameters) Set this option to true to use the prepareStatementStrategy with named parameters. This allows to define queries with named placeholders, and use headers with the dynamic values for the query placeholders. -
getOutputType
-
setOutputType
Determines the output the producer should use. -
getOutputClass
-
setOutputClass
Specify the full package and class name to use as conversion when outputType=SelectOne or SelectList. -
getBeanRowMapper
-
setBeanRowMapper
To use a custom org.apache.camel.component.jdbc.BeanRowMapper when using outputClass. The default implementation will lower case the row names and skip underscores, and dashes. For example "CUST_ID" is mapped as "custId". -
isUseGetBytesForBlob
public boolean isUseGetBytesForBlob() -
setUseGetBytesForBlob
public void setUseGetBytesForBlob(boolean useGetBytesForBlob) To read BLOB columns as bytes instead of string data. This may be needed for certain databases such as Oracle where you must read BLOB columns as bytes. -
getConnectionStrategy
-
setConnectionStrategy
To use a custom strategy for working with connections. Do not use a custom strategy when using the spring-jdbc component because a special Spring ConnectionStrategy is used by default to support Spring Transactions. -
createEndpointUri
- Overrides:
createEndpointUri
in classorg.apache.camel.support.DefaultEndpoint
-