前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【已解决】Flink连接JDBC报错 org.apache.flink.runtime.client.JobExecutionException: Job execution failed.

【已解决】Flink连接JDBC报错 org.apache.flink.runtime.client.JobExecutionException: Job execution failed.

作者头像
火之高兴
发布2024-07-25 15:51:28
2610
发布2024-07-25 15:51:28
举报
文章被收录于专栏:大数据应用技术
代码语言:javascript
复制
Caused by: org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet successfully received from the server was 1,102 milliseconds ago.  The last packet sent successfully to the server was 1,095 milliseconds ago.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

环境:

Flink1.13.6 MySQL5.7.27 JDK8 Hadoop3.1.4 集成环境Idea2020

linux环境
linux环境
Maven依赖
代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>flink-test</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <flink.version>1.13.6</flink.version>
    </properties>

    <dependencies>
        <!--        JDBC            -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.21</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.38</version>
        </dependency>

        <!--        Flink           -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-java</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-streaming-java_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-shaded-hadoop-2-uber</artifactId>
            <version>2.7.5-10.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-jdbc_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-clients_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <!--            Kafka           -->
        <dependency>
            <groupId>org.apache.flink</groupId>
            <artifactId>flink-connector-kafka_2.12</artifactId>
            <version>${flink.version}</version>
        </dependency>

        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>0.11.0.0</version>
        </dependency>
        <!--            Log4j         -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>


    </dependencies>

</project>
报错内容
代码语言:javascript
复制
/*
* 提示:该行代码过长,系统自动注释不进行高亮。一键复制会移除系统注释 
* C:\Users\Lenovo\Documents\jdk\bin\java.exe "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.4\lib\idea_rt.jar=10816:D:\Program Files\JetBrains\IntelliJ IDEA 2020.1.4\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Lenovo\Documents\jdk\jre\lib\charsets.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\deploy.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\access-bridge-64.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\cldrdata.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\dnsns.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\jaccess.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\jfxrt.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\localedata.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\nashorn.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\sunec.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\sunjce_provider.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\sunmscapi.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\sunpkcs11.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\ext\zipfs.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\javaws.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\jce.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\jfr.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\jfxswt.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\jsse.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\management-agent.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\plugin.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\resources.jar;C:\Users\Lenovo\Documents\jdk\jre\lib\rt.jar;D:\BD2302\BD_code\flink-test\target\classes;E:\Maven\repository\org\apache\flink\flink-streaming-java_2.12\1.13.6\flink-streaming-java_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-core\1.13.6\flink-core-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-annotations\1.13.6\flink-annotations-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-metrics-core\1.13.6\flink-metrics-core-1.13.6.jar;E:\Maven\repository\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar;E:\Maven\repository\com\esotericsoftware\kryo\kryo\2.24.0\kryo-2.24.0.jar;E:\Maven\repository\com\esotericsoftware\minlog\minlog\1.2\minlog-1.2.jar;E:\Maven\repository\org\objenesis\objenesis\2.1\objenesis-2.1.jar;E:\Maven\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;E:\Maven\repository\org\apache\commons\commons-compress\1.21\commons-compress-1.21.jar;E:\Maven\repository\org\apache\flink\flink-file-sink-common\1.13.6\flink-file-sink-common-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-runtime_2.12\1.13.6\flink-runtime_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-queryable-state-client-java\1.13.6\flink-queryable-state-client-java-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-hadoop-fs\1.13.6\flink-hadoop-fs-1.13.6.jar;E:\Maven\repository\commons-io\commons-io\2.8.0\commons-io-2.8.0.jar;E:\Maven\repository\org\apache\flink\flink-shaded-netty\4.1.49.Final-13.0\flink-shaded-netty-4.1.49.Final-13.0.jar;E:\Maven\repository\org\apache\flink\flink-shaded-jackson\2.12.1-13.0\flink-shaded-jackson-2.12.1-13.0.jar;E:\Maven\repository\org\apache\flink\flink-shaded-zookeeper-3\3.4.14-13.0\flink-shaded-zookeeper-3-3.4.14-13.0.jar;E:\Maven\repository\org\javassist\javassist\3.24.0-GA\javassist-3.24.0-GA.jar;E:\Maven\repository\org\scala-lang\scala-library\2.12.7\scala-library-2.12.7.jar;E:\Maven\repository\com\typesafe\akka\akka-actor_2.12\2.5.21\akka-actor_2.12-2.5.21.jar;E:\Maven\repository\com\typesafe\config\1.3.3\config-1.3.3.jar;E:\Maven\repository\org\scala-lang\modules\scala-java8-compat_2.12\0.8.0\scala-java8-compat_2.12-0.8.0.jar;E:\Maven\repository\com\typesafe\akka\akka-stream_2.12\2.5.21\akka-stream_2.12-2.5.21.jar;E:\Maven\repository\org\reactivestreams\reactive-streams\1.0.2\reactive-streams-1.0.2.jar;E:\Maven\repository\com\typesafe\ssl-config-core_2.12\0.3.7\ssl-config-core_2.12-0.3.7.jar;E:\Maven\repository\org\scala-lang\modules\scala-parser-combinators_2.12\1.1.1\scala-parser-combinators_2.12-1.1.1.jar;E:\Maven\repository\com\typesafe\akka\akka-protobuf_2.12\2.5.21\akka-protobuf_2.12-2.5.21.jar;E:\Maven\repository\com\typesafe\akka\akka-slf4j_2.12\2.5.21\akka-slf4j_2.12-2.5.21.jar;E:\Maven\repository\org\clapper\grizzled-slf4j_2.12\1.3.2\grizzled-slf4j_2.12-1.3.2.jar;E:\Maven\repository\com\github\scopt\scopt_2.12\3.5.0\scopt_2.12-3.5.0.jar;E:\Maven\repository\com\twitter\chill_2.12\0.7.6\chill_2.12-0.7.6.jar;E:\Maven\repository\com\twitter\chill-java\0.7.6\chill-java-0.7.6.jar;E:\Maven\repository\org\lz4\lz4-java\1.6.0\lz4-java-1.6.0.jar;E:\Maven\repository\org\apache\flink\flink-java\1.13.6\flink-java-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-shaded-guava\18.0-13.0\flink-shaded-guava-18.0-13.0.jar;E:\Maven\repository\org\apache\commons\commons-math3\3.5\commons-math3-3.5.jar;E:\Maven\repository\org\slf4j\slf4j-api\1.7.15\slf4j-api-1.7.15.jar;E:\Maven\repository\com\google\code\findbugs\jsr305\1.3.9\jsr305-1.3.9.jar;E:\Maven\repository\org\apache\flink\force-shading\1.13.6\force-shading-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-clients_2.12\1.13.6\flink-clients_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-optimizer_2.12\1.13.6\flink-optimizer_2.12-1.13.6.jar;E:\Maven\repository\commons-cli\commons-cli\1.3.1\commons-cli-1.3.1.jar;E:\Maven\repository\org\apache\flink\flink-table-api-java-bridge_2.12\1.13.6\flink-table-api-java-bridge_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-table-api-java\1.13.6\flink-table-api-java-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-table-planner-blink_2.12\1.13.6\flink-table-planner-blink_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-table-api-scala_2.12\1.13.6\flink-table-api-scala_2.12-1.13.6.jar;E:\Maven\repository\org\scala-lang\scala-reflect\2.12.7\scala-reflect-2.12.7.jar;E:\Maven\repository\org\scala-lang\scala-compiler\2.12.7\scala-compiler-2.12.7.jar;E:\Maven\repository\org\scala-lang\modules\scala-xml_2.12\1.0.6\scala-xml_2.12-1.0.6.jar;E:\Maven\repository\org\apache\flink\flink-table-api-scala-bridge_2.12\1.13.6\flink-table-api-scala-bridge_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-scala_2.12\1.13.6\flink-scala_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-streaming-scala_2.12\1.13.6\flink-streaming-scala_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-table-runtime-blink_2.12\1.13.6\flink-table-runtime-blink_2.12-1.13.6.jar;E:\Maven\repository\org\codehaus\janino\janino\3.0.11\janino-3.0.11.jar;E:\Maven\repository\org\codehaus\janino\commons-compiler\3.0.11\commons-compiler-3.0.11.jar;E:\Maven\repository\org\apache\calcite\avatica\avatica-core\1.17.0\avatica-core-1.17.0.jar;E:\Maven\repository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar;E:\Maven\repository\com\ververica\flink-connector-mysql-cdc\2.1.0\flink-connector-mysql-cdc-2.1.0.jar;E:\Maven\repository\com\ververica\flink-connector-debezium\2.1.0\flink-connector-debezium-2.1.0.jar;E:\Maven\repository\io\debezium\debezium-api\1.5.4.Final\debezium-api-1.5.4.Final.jar;E:\Maven\repository\io\debezium\debezium-embedded\1.5.4.Final\debezium-embedded-1.5.4.Final.jar;E:\Maven\repository\org\apache\kafka\connect-api\2.7.0\connect-api-2.7.0.jar;E:\Maven\repository\javax\ws\rs\javax.ws.rs-api\2.1.1\javax.ws.rs-api-2.1.1.jar;E:\Maven\repository\org\apache\kafka\connect-runtime\2.7.0\connect-runtime-2.7.0.jar;E:\Maven\repository\org\apache\kafka\kafka-tools\2.7.0\kafka-tools-2.7.0.jar;E:\Maven\repository\net\sourceforge\argparse4j\argparse4j\0.7.0\argparse4j-0.7.0.jar;E:\Maven\repository\org\apache\kafka\connect-transforms\2.7.0\connect-transforms-2.7.0.jar;E:\Maven\repository\com\fasterxml\jackson\jaxrs\jackson-jaxrs-json-provider\2.10.5\jackson-jaxrs-json-provider-2.10.5.jar;E:\Maven\repository\com\fasterxml\jackson\jaxrs\jackson-jaxrs-base\2.10.5\jackson-jaxrs-base-2.10.5.jar;E:\Maven\repository\com\fasterxml\jackson\module\jackson-module-jaxb-annotations\2.10.5\jackson-module-jaxb-annotations-2.10.5.jar;E:\Maven\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.2\jakarta.xml.bind-api-2.3.2.jar;E:\Maven\repository\jakarta\activation\jakarta.activation-api\1.2.1\jakarta.activation-api-1.2.1.jar;E:\Maven\repository\org\glassfish\jersey\containers\jersey-container-servlet\2.31\jersey-container-servlet-2.31.jar;E:\Maven\repository\org\glassfish\jersey\containers\jersey-container-servlet-core\2.31\jersey-container-servlet-core-2.31.jar;E:\Maven\repository\org\glassfish\hk2\external\jakarta.inject\2.6.1\jakarta.inject-2.6.1.jar;E:\Maven\repository\jakarta\ws\rs\jakarta.ws.rs-api\2.1.6\jakarta.ws.rs-api-2.1.6.jar;E:\Maven\repository\org\glassfish\jersey\inject\jersey-hk2\2.31\jersey-hk2-2.31.jar;E:\Maven\repository\org\glassfish\hk2\hk2-locator\2.6.1\hk2-locator-2.6.1.jar;E:\Maven\repository\org\glassfish\hk2\external\aopalliance-repackaged\2.6.1\aopalliance-repackaged-2.6.1.jar;E:\Maven\repository\org\glassfish\hk2\hk2-api\2.6.1\hk2-api-2.6.1.jar;E:\Maven\repository\org\glassfish\hk2\hk2-utils\2.6.1\hk2-utils-2.6.1.jar;E:\Maven\repository\javax\xml\bind\jaxb-api\2.3.0\jaxb-api-2.3.0.jar;E:\Maven\repository\javax\activation\activation\1.1.1\activation-1.1.1.jar;E:\Maven\repository\org\eclipse\jetty\jetty-server\9.4.33.v20201020\jetty-server-9.4.33.v20201020.jar;E:\Maven\repository\javax\servlet\javax.servlet-api\3.1.0\javax.servlet-api-3.1.0.jar;E:\Maven\repository\org\eclipse\jetty\jetty-http\9.4.33.v20201020\jetty-http-9.4.33.v20201020.jar;E:\Maven\repository\org\eclipse\jetty\jetty-io\9.4.33.v20201020\jetty-io-9.4.33.v20201020.jar;E:\Maven\repository\org\eclipse\jetty\jetty-servlet\9.4.33.v20201020\jetty-servlet-9.4.33.v20201020.jar;E:\Maven\repository\org\eclipse\jetty\jetty-security\9.4.33.v20201020\jetty-security-9.4.33.v20201020.jar;E:\Maven\repository\org\eclipse\jetty\jetty-servlets\9.4.33.v20201020\jetty-servlets-9.4.33.v20201020.jar;E:\Maven\repository\org\eclipse\jetty\jetty-continuation\9.4.33.v20201020\jetty-continuation-9.4.33.v20201020.jar;E:\Maven\repository\org\eclipse\jetty\jetty-util\9.4.33.v20201020\jetty-util-9.4.33.v20201020.jar;E:\Maven\repository\org\eclipse\jetty\jetty-client\9.4.33.v20201020\jetty-client-9.4.33.v20201020.jar;E:\Maven\repository\org\reflections\reflections\0.9.12\reflections-0.9.12.jar;E:\Maven\repository\org\apache\maven\maven-artifact\3.6.3\maven-artifact-3.6.3.jar;E:\Maven\repository\org\codehaus\plexus\plexus-utils\3.2.1\plexus-utils-3.2.1.jar;E:\Maven\repository\org\apache\kafka\connect-json\2.7.0\connect-json-2.7.0.jar;E:\Maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.5\jackson-datatype-jdk8-2.10.5.jar;E:\Maven\repository\org\apache\kafka\connect-file\2.7.0\connect-file-2.7.0.jar;E:\Maven\repository\io\debezium\debezium-connector-mysql\1.5.4.Final\debezium-connector-mysql-1.5.4.Final.jar;E:\Maven\repository\io\debezium\debezium-core\1.5.4.Final\debezium-core-1.5.4.Final.jar;E:\Maven\repository\com\fasterxml\jackson\core\jackson-core\2.10.5\jackson-core-2.10.5.jar;E:\Maven\repository\com\fasterxml\jackson\core\jackson-databind\2.10.5\jackson-databind-2.10.5.jar;E:\Maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.5\jackson-annotations-2.10.5.jar;E:\Maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.5\jackson-datatype-jsr310-2.10.5.jar;E:\Maven\repository\com\google\guava\guava\30.0-jre\guava-30.0-jre.jar;E:\Maven\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;E:\Maven\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;E:\Maven\repository\io\debezium\debezium-ddl-parser\1.5.4.Final\debezium-ddl-parser-1.5.4.Final.jar;E:\Maven\repository\org\antlr\antlr4-runtime\4.7.2\antlr4-runtime-4.7.2.jar;E:\Maven\repository\com\zendesk\mysql-binlog-connector-java\0.25.1\mysql-binlog-connector-java-0.25.1.jar;E:\Maven\repository\com\esri\geometry\esri-geometry-api\2.2.0\esri-geometry-api-2.2.0.jar;E:\Maven\repository\com\zaxxer\HikariCP\4.0.3\HikariCP-4.0.3.jar;E:\Maven\repository\org\apache\flink\flink-table-common\1.13.6\flink-table-common-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-connector-files\1.13.6\flink-connector-files-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-shaded-asm-7\7.1-13.0\flink-shaded-asm-7-7.1-13.0.jar;E:\Maven\repository\org\apache\flink\flink-json\1.13.6\flink-json-1.13.6.jar;E:\Maven\repository\org\projectlombok\lombok\1.18.24\lombok-1.18.24.jar;E:\Maven\repository\com\alibaba\fastjson\1.2.78\fastjson-1.2.78.jar;E:\Maven\repository\redis\clients\jedis\3.2.0\jedis-3.2.0.jar;E:\Maven\repository\org\apache\commons\commons-pool2\2.6.2\commons-pool2-2.6.2.jar;E:\Maven\repository\org\apache\flink\flink-shaded-hadoop-2-uber\2.6.5-10.0\flink-shaded-hadoop-2-uber-2.6.5-10.0.jar;E:\Maven\repository\org\slf4j\slf4j-log4j12\1.7.15\slf4j-log4j12-1.7.15.jar;E:\Maven\repository\log4j\log4j\1.2.17\log4j-1.2.17.jar;E:\Maven\repository\org\apache\flink\flink-connector-jdbc_2.12\1.13.6\flink-connector-jdbc_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-connector-kafka_2.12\1.13.6\flink-connector-kafka_2.12-1.13.6.jar;E:\Maven\repository\org\apache\flink\flink-connector-base\1.13.6\flink-connector-base-1.13.6.jar;E:\Maven\repository\org\apache\bahir\flink-connector-redis_2.12\1.1.0\flink-connector-redis_2.12-1.1.0.jar;E:\Maven\repository\cn\hutool\hutool-json\5.8.5\hutool-json-5.8.5.jar;E:\Maven\repository\cn\hutool\hutool-core\5.8.5\hutool-core-5.8.5.jar;E:\Maven\repository\org\apache\kafka\kafka-clients\0.11.0.0\kafka-clients-0.11.0.0.jar;E:\Maven\repository\net\jpountz\lz4\lz4\1.3.0\lz4-1.3.0.jar;E:\Maven\repository\org\xerial\snappy\snappy-java\1.1.2.6\snappy-java-1.1.2.6.jar day10610.FlinkJDBC
*/
log4j:WARN No appenders could be found for logger (org.apache.flink.api.java.ClosureCleaner).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
	at org.apache.flink.runtime.jobmaster.JobResult.toJobExecutionResult(JobResult.java:144)
	at org.apache.flink.runtime.minicluster.MiniClusterJobClient.lambda$getJobExecutionResult$3(MiniClusterJobClient.java:137)
	at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:616)
	at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:591)
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
	at org.apache.flink.runtime.rpc.akka.AkkaInvocationHandler.lambda$invokeRpc$0(AkkaInvocationHandler.java:237)
	at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:774)
	at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:750)
	at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:488)
	at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1975)
	at org.apache.flink.runtime.concurrent.FutureUtils$1.onComplete(FutureUtils.java:1081)
	at akka.dispatch.OnComplete.internal(Future.scala:264)
	at akka.dispatch.OnComplete.internal(Future.scala:261)
	at akka.dispatch.japi$CallbackBridge.apply(Future.scala:191)
	at akka.dispatch.japi$CallbackBridge.apply(Future.scala:188)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
	at org.apache.flink.runtime.concurrent.Executors$DirectExecutionContext.execute(Executors.java:73)
	at scala.concurrent.impl.CallbackRunnable.executeWithValue(Promise.scala:68)
	at scala.concurrent.impl.Promise$DefaultPromise.$anonfun$tryComplete$1(Promise.scala:284)
	at scala.concurrent.impl.Promise$DefaultPromise.$anonfun$tryComplete$1$adapted(Promise.scala:284)
	at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:284)
	at akka.pattern.PromiseActorRef.$bang(AskSupport.scala:573)
	at akka.pattern.PipeToSupport$PipeableFuture$$anonfun$pipeTo$1.applyOrElse(PipeToSupport.scala:22)
	at akka.pattern.PipeToSupport$PipeableFuture$$anonfun$pipeTo$1.applyOrElse(PipeToSupport.scala:21)
	at scala.concurrent.Future.$anonfun$andThen$1(Future.scala:532)
	at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
	at scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
	at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
	at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)
	at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)
	at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44)
	at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: org.apache.flink.runtime.JobException: Recovery is suppressed by NoRestartBackoffTimeStrategy
	at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.handleFailure(ExecutionFailureHandler.java:138)
	at org.apache.flink.runtime.executiongraph.failover.flip1.ExecutionFailureHandler.getFailureHandlingResult(ExecutionFailureHandler.java:82)
	at org.apache.flink.runtime.scheduler.DefaultScheduler.handleTaskFailure(DefaultScheduler.java:216)
	at org.apache.flink.runtime.scheduler.DefaultScheduler.maybeHandleTaskFailure(DefaultScheduler.java:206)
	at org.apache.flink.runtime.scheduler.DefaultScheduler.updateTaskExecutionStateInternal(DefaultScheduler.java:197)
	at org.apache.flink.runtime.scheduler.SchedulerBase.updateTaskExecutionState(SchedulerBase.java:682)
	at org.apache.flink.runtime.scheduler.SchedulerNG.updateTaskExecutionState(SchedulerNG.java:79)
	at org.apache.flink.runtime.jobmaster.JobMaster.updateTaskExecutionState(JobMaster.java:435)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcInvocation(AkkaRpcActor.java:305)
	at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleRpcMessage(AkkaRpcActor.java:212)
	at org.apache.flink.runtime.rpc.akka.FencedAkkaRpcActor.handleRpcMessage(FencedAkkaRpcActor.java:77)
	at org.apache.flink.runtime.rpc.akka.AkkaRpcActor.handleMessage(AkkaRpcActor.java:158)
	at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:26)
	at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:21)
	at scala.PartialFunction.applyOrElse(PartialFunction.scala:123)
	at scala.PartialFunction.applyOrElse$(PartialFunction.scala:122)
	at akka.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:21)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:171)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
	at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:172)
	at akka.actor.Actor.aroundReceive(Actor.scala:517)
	at akka.actor.Actor.aroundReceive$(Actor.scala:515)
	at akka.actor.AbstractActor.aroundReceive(AbstractActor.scala:225)
	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:592)
	at akka.actor.ActorCell.invoke(ActorCell.scala:561)
	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:258)
	at akka.dispatch.Mailbox.run(Mailbox.scala:225)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:235)
	... 4 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 1,102 milliseconds ago.  The last packet sent successfully to the server was 1,095 milliseconds ago.
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
	at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
	at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:164)
	at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4801)
	at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1643)
	at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1215)
	at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2255)
	at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286)
	at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)
	at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
	at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
	at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:247)
	at day10610.FlinkJDBC$MySQLSink.open(FlinkJDBC.java:35)
	at org.apache.flink.api.common.functions.util.FunctionUtils.openFunction(FunctionUtils.java:34)
	at org.apache.flink.streaming.api.operators.AbstractUdfStreamOperator.open(AbstractUdfStreamOperator.java:102)
	at org.apache.flink.streaming.api.operators.StreamSink.open(StreamSink.java:46)
	at org.apache.flink.streaming.runtime.tasks.OperatorChain.initializeStateAndOpenOperators(OperatorChain.java:442)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restoreGates(StreamTask.java:585)
	at org.apache.flink.streaming.runtime.tasks.StreamTaskActionExecutor$1.call(StreamTaskActionExecutor.java:55)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.executeRestore(StreamTask.java:565)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.runWithCleanUpOnFail(StreamTask.java:650)
	at org.apache.flink.streaming.runtime.tasks.StreamTask.restore(StreamTask.java:540)
	at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:759)
	at org.apache.flink.runtime.taskmanager.Task.run(Task.java:566)
	at java.lang.Thread.run(Thread.java:750)
Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
	at sun.security.ssl.HandshakeContext.<init>(HandshakeContext.java:171)
	at sun.security.ssl.ClientHandshakeContext.<init>(ClientHandshakeContext.java:106)
	at sun.security.ssl.TransportContext.kickstart(TransportContext.java:238)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:410)
	at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:389)
	at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:149)
	... 30 more

Process finished with exit code 1
运行代码
代码语言:javascript
复制
package day10610;

import org.apache.flink.api.common.RuntimeExecutionMode;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class FlinkJDBC {

    public static void main(String[] args) throws Exception {
        //TODO 1.env-准备环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setRuntimeMode(RuntimeExecutionMode.AUTOMATIC);
        //TODO 2.source-加载数据
        DataStream<Student> studentDS = env.fromElements(new Student(0, "lucy", 19));
        //TODO 3.transformation-数据转换处理
        //TODO 4.sink-数据输出
        studentDS.addSink(new MySQLSink());
        //TODO 5.execute-执行
        env.execute();
    }

    private static class MySQLSink extends RichSinkFunction<Student> {
        Connection conn = null;
        PreparedStatement ps = null;

        //连接JDBC一次
        @Override
        public void open(Configuration parameters) throws Exception {
            conn = DriverManager.getConnection("jdbc:mysql://hadoop10:3306/yangyulin?useSSL=true", "root", "0000");
            ps = conn.prepareStatement("INSERT INTO `t_student` (`id`, `name`, `age`) VALUES (999, ?, ?)");
        }

        @Override
        public void invoke(Student value, Context context) throws Exception {
            //设置?占位符参数
            ps.setString(1, value.getName());
            ps.setInt(2, value.getAge());
            //执行SQL将数据插入到MySQL
            ps.executeUpdate();
        }

        //关闭JDBC一次
        @Override
        public void close() throws Exception {
            if (conn != null) conn.close();
            if (ps != null) ps.close();

        }
    }
}

###修改代码

代码语言:javascript
复制
 conn = DriverManager.getConnection("jdbc:mysql://hadoop10:3306/yangyulin?useSSL=true", "root", "0000");

修改为

代码语言:javascript
复制
conn = DriverManager.getConnection("jdbc:mysql://hadoop10:3306/yangyulin?useSSL=false", "root", "0000");

true修改为false即可


2023-6-28更新: Job execution failed.这个报错是Flink给出job中的运行时异常,需要做的是查看log,检查业务代码中的逻辑。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-06-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 环境:
  • Maven依赖
  • 报错内容
  • 运行代码
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档