All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.shanqiang.sp.input.MysqlFetcher Maven / Gradle / Ivy

package io.github.shanqiang.sp.input;

import io.github.shanqiang.table.Type;
import com.mysql.cj.jdbc.MysqlDataSource;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;

public class MysqlFetcher extends JdbcFetcher {
    public MysqlFetcher(String jdbcUrl,
                        String userName,
                        String password,
                        Map columnTypeMap) throws SQLException {
        super(columnTypeMap, connection(jdbcUrl, userName, password));
    }

    private static Connection connection(String jdbcUrl,
                                         String userName,
                                         String password) throws SQLException {
        MysqlDataSource dataSource = new MysqlDataSource();
        dataSource.setUrl(jdbcUrl);
        dataSource.setUser(userName);
        dataSource.setPassword(password);
        dataSource.setAutoReconnect(true);
        return dataSource.getConnection();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy