use of au.com.mineauz.minigames.backend.ConnectionPool in project Minigames by AddstarMC.
the class MySQLBackend method initialize.
@Override
public boolean initialize(ConfigurationSection config) {
try {
Class.forName("com.mysql.jdbc.Driver");
database = config.getString("database", "database");
// Create the pool
String url = String.format("jdbc:mysql://%s/%s", config.getString("host", "localhost:3306"), database);
Properties properties = new Properties();
properties.put("user", config.getString("username", "username"));
properties.put("password", config.getString("password", "password"));
properties.put("useSSL", config.getBoolean("useSSL", false));
pool = new ConnectionPool(url, properties);
createStatements();
// Test the connection
try {
ConnectionHandler handler = pool.getConnection();
ensureTables(handler);
handler.release();
return true;
} catch (SQLException e) {
logger.severe("Failed to connect to the MySQL database. Please check your database settings");
}
} catch (ClassNotFoundException e) {
logger.severe("Failed to find MySQL JDBC driver. This version of craftbukkit is defective.");
}
return false;
}
use of au.com.mineauz.minigames.backend.ConnectionPool in project Minigames by AddstarMC.
the class SQLiteBackend method initialize.
@Override
public boolean initialize(ConfigurationSection config) {
try {
Class.forName("org.sqlite.JDBC");
// Create the pool
File path = new File(Minigames.plugin.getDataFolder(), "minigames.db");
String url = String.format("jdbc:sqlite:" + path.getAbsolutePath());
Properties properties = new Properties();
properties.put("username", "");
properties.put("password", "");
pool = new ConnectionPool(url, properties);
createStatements();
// Test the connection
try {
ConnectionHandler handler = pool.getConnection();
ensureTables(handler);
handler.release();
return true;
} catch (SQLException e) {
logger.severe("Failed to connect to the SQLite database. Please check your database settings");
}
} catch (ClassNotFoundException e) {
logger.severe("Failed to find sqlite JDBC driver. This version of craftbukkit is defective.");
}
return false;
}
Aggregations