Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. package me.fabricio.fire.clans.sql;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. import org.bukkit.Bukkit;
  8.  
  9. import me.fabricio.fire.clans.Main;
  10.  
  11. public class Conectar {
  12.  
  13. public static Conectar getInstance() {
  14. Conectar instancia = new Conectar();
  15. return instancia;
  16. }
  17.  
  18. public void ExecutarConexao() {
  19. Connection con = null;
  20. try {
  21. String connect = "jdbc:sqlite:C:/sqlite/db/fireclans.db";
  22. con = DriverManager.getConnection(connect);
  23. Bukkit.getConsoleSender().sendMessage("§6[FireClans] §fFoi estabelecida a conexão com o SQLite.");
  24. } catch (SQLException e) {
  25. Bukkit.getConsoleSender().sendMessage("§6[FireClans] §cERRO FATAL! Não foi possível estabelecer conexão com o SQLite, desabilitando plugin...");
  26. Bukkit.getPluginManager().disablePlugin(Main.getPlugin(Main.class));
  27. } finally {
  28. try {
  29. if (con != null) {
  30. con.close();
  31. }
  32. } catch (SQLException ex) {
  33. Bukkit.getConsoleSender().sendMessage("§6[FireClans] §aConexão estabelecida.");
  34. }
  35. }
  36. }
  37.  
  38. public void CriarBanco(String nome) {
  39. String db = "jdbc:sqlite:C:/sqlite/db/" + nome + ".db";
  40. try (Connection con = DriverManager.getConnection(db)){
  41. if (con != null) {
  42. return;
  43. }
  44. } catch (SQLException e) {
  45. System.out.println(e.getMessage());
  46. }
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement