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 H2Database extends Database{
    protected H2Database(HikariDataSource ds) {
        super(ds, "");
        Database.instance = this;
    }

    @Override
    boolean isTableExists(String name, Connection con) throws SQLException {
        PreparedStatement st = con.prepareStatement("SELECT * FROM information_schema.tables WHERE table_name = ?");
        st.setString(1, name.toUpperCase());
        ResultSet rs = st.executeQuery();
        return rs.next();
    }
}
