Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de._Kally_.CoinSystem.MySQL;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- public class MySQL {
- static String host = "localhost";
- static String port = "3306";
- static String database = "plugins";
- static String username = "plugins";
- static String password = "ycwPzTt5uGarbkTz";
- public static Connection con;
- //Host: localhost
- //Port: 3306
- //Database: plugins
- //password: plugins
- //username: plugins
- public static void connect() {
- if(!isConnected()) {
- try {
- con = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
- System.out.println("[CoinSystem] MySQL verbunden!");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static void disconnect() {
- if(isConnected()) {
- try {
- con.close();
- System.out.println("[CoinSystem] MySQL geschlossen!");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected() {
- return (con == null ? false :true);
- }
- public static void update(String qry) {
- try {
- PreparedStatement ps = con.prepareStatement(qry);
- ps.executeUpdate();
- } catch (SQLException e) {
- }
- }
- public static ResultSet getResult(String qry) {
- try {
- PreparedStatement ps = con.prepareStatement(qry);
- return ps.executeQuery();
- }catch(SQLException e) {
- e.printStackTrace();
- }
- return null;
- }
- public static PreparedStatement getStatement(String sql){
- if(isConnected()){
- PreparedStatement ps;
- try {
- ps = con.prepareStatement(sql);
- return ps;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement