Guest User

Untitled

a guest
Nov 19th, 2016
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. package Ban;
  2.  
  3. import java.sql.DriverManager;
  4. import java.sql.SQLException;
  5.  
  6. import com.mysql.jdbc.Connection;
  7.  
  8. public class MySQL {
  9.  
  10. private static Connection c;
  11.  
  12. public static void connect(String host, String user, String password, String database){
  13. try{
  14. c = (Connection) DriverManager.getConnection("jdbc:mysql://" + host + ":3306/" + database + "?autoReconnect=true", user , password);
  15.  
  16. System.out.println("[MySQL] Verbuden");
  17. }catch(SQLException e){
  18. System.out.println("[Fehler] " + e.getMessage());
  19. }
  20. }
  21.  
  22. public static void update(String sql){
  23. try {
  24. c.createStatement().executeUpdate(sql);
  25. } catch (SQLException e) {
  26. System.out.println("[Fehler] " + e.getMessage());
  27. }
  28. }
  29.  
  30. public static Connection getConnection(){
  31. return c;
  32. }
  33.  
  34. }
Add Comment
Please, Sign In to add comment