zhaomin1423 commented on pull request #1390: URL: https://github.com/apache/incubator-seatunnel/pull/1390#issuecomment-1058731012
The pre sqls and post sqls are executed in driver, the output is executed in executors. They can not use a connection. The post sqls use a new connection because the output can be running a long time, a new connection is better for using. | | ***@***.*** | | ***@***.*** | ---- 回复的原邮件 ---- | 发件人 | ***@***.***> | | 日期 | 2022年03月04日 08:57 | | 收件人 | ***@***.***> | | 抄送至 | Xiao ***@***.******@***.***> | | 主题 | Re: [apache/incubator-seatunnel] [Feature][spark-connector-jdbc] add pre sql and post sql #1386 (PR #1390) | @yx91490 commented on this pull request. In seatunnel-connectors/seatunnel-connector-spark-jdbc/src/main/scala/org/apache/seatunnel/spark/JdbcConfigs.scala: > + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.seatunnel.spark is JdbcConfigs.scala will be shared by source and sink? if not, maybe can move to org.apache.seatunnel.spark.sink package. In seatunnel-connectors/seatunnel-connector-spark-jdbc/src/main/scala/org/apache/seatunnel/spark/sink/Jdbc.scala: > class Jdbc extends SparkBatchSink { + private val LOG: Logger = LoggerFactory.getLogger(classOf[Jdbc]) + + private var jdbcConfigs: JdbcConfigs = _ + + private def getConnection(): Connection = { + Class.forName(jdbcConfigs.driver) + val connection = DriverManager.getConnection(jdbcConfigs.url, jdbcConfigs.user, jdbcConfigs.password) It seems that connection will be created about 3 times at worst, can connection be reused in the same job? — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: ***@***.***> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
