Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.theTrixxter.mysql;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import org.bukkit.plugin.Plugin;
- public abstract class database {
- public Connection con;
- public Plugin plugin;
- public database(Plugin plugin){
- this.plugin = plugin;
- this.con = null;
- }
- public abstract Connection openConnection() throws SQLException,
- ClassNotFoundException;
- public boolean checkConnection() throws SQLException{
- return con != null && !con.isClosed();
- }
- public Connection getConnection(){
- return con;
- }
- public boolean closeConnection() throws SQLException{
- if(con == null){
- return false;
- }
- con.close();
- return true;
- }
- public ResultSet querySQL(String s) throws SQLException,
- ClassNotFoundException{
- if(!checkConnection()){
- openConnection();
- }
- Statement st = con.createStatement();
- ResultSet rs = st.executeQuery(s);
- return rs;
- }
- public int updateSQL(String s) throws SQLException,
- ClassNotFoundException{
- if(!checkConnection()){
- openConnection();
- }
- Statement st = con.createStatement();
- int rs = st.executeUpdate(s);
- return rs;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement