<from uri="sql:select * from params?dataSource=moodleDB"/>
异常(exception):
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.ConnectException
MESSAGE: Connection refused: connect
STACKTRACE:
java.net.ConnectException: Connection refused: connect
我怎样才能捕捉到这个异常?
最佳答案
通常从端点不会抛出异常,我会尝试使用其他东西来启动您的程序,然后我会跟进一个异常处理程序。如果您想要重试,错误处理程序将从失败的任何步骤重试,并且您可以为不同的异常类型设置不同的行为。此错误处理程序将用于您的整个上下文,但您也可以在路由级别设置它们。可以在此处找到更多信息:http://camel.apache.org/error-handling-in-camel.html
onException(Exception.class)
.handled(true)
.log(LoggingLevel.ERROR, "${exception.stackTrace}")
.stop();
from("timer://RunOnStartupOnceTimer?repeatCount=1")
.to("sql:select * from params?dataSource=moodleDB")
.to("moreProcessing");
关于mysql - 我如何处理 CAMEL jdbc 连接异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33034704/