Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.bausucht.enrico.coinsystem;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- public class MySQL {
- public static String host = "173.212.248.242";
- public static String port = "3306";
- public static String database = "Enrico_A007-BauSucht-JavaTest";
- public static String username = "Enrico_A007";
- public static String password = "i98B2fiaUrsQoPJQMsvN";
- public static Connection con;
- public static void connect() {
- if(!(isConnected())) {
- try {
- con = DriverManager.getConnection("jdbc::mysql:://" + host + ":" + port + "/" + database, username, password);
- }catch(SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static void disconnect() {
- if(isConnected()) {
- try {
- con.close();
- }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) {
- e.printStackTrace();
- }
- }
- public static ResultSet getResult(String qry) {
- PreparedStatement ps;
- try {
- ps = con.prepareStatement(qry);
- return ps.executeQuery();
- } catch (SQLException e) {
- e.printStackTrace();
- }catch (NullPointerException e) {
- e.printStackTrace();
- }
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement