package ru.redguy.qseller;

import com.zaxxer.hikari.HikariDataSource;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class MySQLDatabase extends Database{
    protected MySQLDatabase(HikariDataSource ds, String tablePrefix) {
        super(ds, tablePrefix);
        Database.instance = this;
    }

    @Override
    boolean isTableExists(String name, Connection con) throws SQLException {
        PreparedStatement st = con.prepareStatement("SHOW TABLES LIKE ?");
        st.setString(1, this.getPrefix() + name);
        ResultSet rs = st.executeQuery();
        return rs.next();
    }
}
