import java.sql.SQLException; import java.util.Properties; import org.mariadb.jdbc.Configuration; import org.mariadb.jdbc.Connection; import org.mariadb.jdbc.Driver; public class Mariadb implements DataSource{ String user = "sargabt"; String pass = "titok"; String host; String name; String url; public Mariadb(Properties pro) { this.host = pro.getProperty("db.host"); this.name = pro.getProperty("db.name"); this.user = pro.getProperty("db.user"); this.pass = pro.getProperty("db.pass"); this.url = "jdbc:mariadb://" + host + ":3306/" + name + "?user=" + user + "&password=" + pass; } public Connection connect() { Connection conn = null; try { conn = tryConnect(); } catch (SQLException e) { System.err.println("Hiba! A kapcsolódás sikertelen!"); System.err.println(e.getMessage()); } return conn; } public Connection tryConnect() throws SQLException { Configuration conf = Configuration.parse(url); Connection conn = Driver.connect(conf); return conn; } }