Sha256: a759111b5539cbe0e392ff7ec020c42c60453009420e87c63d9ca0e9fe643e63

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

package org.embulk.output.mysql;

import java.util.Properties;
import java.sql.Driver;
import java.sql.Connection;
import java.sql.SQLException;
import org.embulk.output.jdbc.JdbcOutputConnector;
import org.embulk.output.jdbc.JdbcOutputConnection;

public class MySQLOutputConnector
        implements JdbcOutputConnector
{
    private final Driver driver;
    private final String url;
    private final Properties properties;

    public MySQLOutputConnector(String url, Properties properties)
    {
        try {
            this.driver = new com.mysql.jdbc.Driver();  // new com.mysql.jdbc.Driver throws SQLException
        } catch (SQLException ex) {
            throw new RuntimeException(ex);
        }
        this.url = url;
        this.properties = properties;
    }

    @Override
    public MySQLOutputConnection connect(boolean autoCommit) throws SQLException
    {
        Connection c = driver.connect(url, properties);
        try {
            MySQLOutputConnection con = new MySQLOutputConnection(c, autoCommit);
            c = null;
            return con;
        } finally {
            if (c != null) {
                c.close();
            }
        }
    }
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
embulk-output-mysql-0.4.1 src/main/java/org/embulk/output/mysql/MySQLOutputConnector.java
embulk-output-mysql-0.2.4 src/main/java/org/embulk/output/mysql/MySQLOutputConnector.java