Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.fabricio.fire.clans.sql;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import org.bukkit.Bukkit;
- import me.fabricio.fire.clans.Main;
- public class Conectar {
- public static Conectar getInstance() {
- Conectar instancia = new Conectar();
- return instancia;
- }
- public void ExecutarConexao() {
- Connection con = null;
- try {
- String connect = "jdbc:sqlite:C:/sqlite/db/fireclans.db";
- con = DriverManager.getConnection(connect);
- Bukkit.getConsoleSender().sendMessage("§6[FireClans] §fFoi estabelecida a conexão com o SQLite.");
- } catch (SQLException e) {
- Bukkit.getConsoleSender().sendMessage("§6[FireClans] §cERRO FATAL! Não foi possível estabelecer conexão com o SQLite, desabilitando plugin...");
- Bukkit.getPluginManager().disablePlugin(Main.getPlugin(Main.class));
- } finally {
- try {
- if (con != null) {
- con.close();
- }
- } catch (SQLException ex) {
- Bukkit.getConsoleSender().sendMessage("§6[FireClans] §aConexão estabelecida.");
- }
- }
- }
- public void CriarBanco(String nome) {
- String db = "jdbc:sqlite:C:/sqlite/db/" + nome + ".db";
- try (Connection con = DriverManager.getConnection(db)){
- if (con != null) {
- return;
- }
- } catch (SQLException e) {
- System.out.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement