ruanwenjun commented on code in PR #10406: URL: https://github.com/apache/dolphinscheduler/pull/10406#discussion_r894985003
########## dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-mysql/src/main/java/org/apache/dolphinscheduler/plugin/registry/mysql/MysqlOperator.java: ########## @@ -0,0 +1,294 @@ +/* + * 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.dolphinscheduler.plugin.registry.mysql; + +import org.apache.dolphinscheduler.common.utils.NetUtils; +import org.apache.dolphinscheduler.plugin.registry.mysql.model.DataType; +import org.apache.dolphinscheduler.plugin.registry.mysql.model.MysqlRegistryData; +import org.apache.dolphinscheduler.plugin.registry.mysql.model.MysqlRegistryLock; + +import org.apache.commons.lang3.StringUtils; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLIntegrityConstraintViolationException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.List; + +import javax.sql.DataSource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Used to CRUD from mysql + */ +public class MysqlOperator { + + private static final Logger logger = LoggerFactory.getLogger(MysqlOperator.class); + + private final DataSource dataSource; + + public MysqlOperator(DataSource dataSource) { + this.dataSource = dataSource; + } + + public void healthCheck() throws SQLException { + String sql = "select 1 from t_ds_mysql_registry_data"; + try (Connection connection = dataSource.getConnection(); + PreparedStatement preparedStatement = connection.prepareStatement(sql)) { + // if no exception, the healthCheck success + preparedStatement.executeQuery(); + } + } + + public List<MysqlRegistryData> queryAllMysqlRegistryData() throws SQLException { + String sql = "select id, `key`, data, type, createTime, lastUpdateTime from t_ds_mysql_registry_data"; Review Comment: This module will not rely on dao module, if we hope to use mybatis here may need to do other config like mapper scan. This can be optimized latter. -- 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]
