Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Ban;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import com.mysql.jdbc.Connection;
- public class MySQL {
- private static Connection c;
- public static void connect(String host, String user, String password, String database){
- try{
- c = (Connection) DriverManager.getConnection("jdbc:mysql://" + host + ":3306/" + database + "?autoReconnect=true", user , password);
- System.out.println("[MySQL] Verbuden");
- }catch(SQLException e){
- System.out.println("[Fehler] " + e.getMessage());
- }
- }
- public static void update(String sql){
- try {
- c.createStatement().executeUpdate(sql);
- } catch (SQLException e) {
- System.out.println("[Fehler] " + e.getMessage());
- }
- }
- public static Connection getConnection(){
- return c;
- }
- }
Add Comment
Please, Sign In to add comment