Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SQL {
- public static Connection connection;
- public static String SQLiteCreateTokensTable = "CREATE TABLE IF NOT EXISTS SkyBlock_Day(UUID VARCHAR(100), Day INT, Time LONG, TimeAfter LONG);";
- public static String table = "SkyBlock_Day";
- public static Connection getSQLConnection() {
- File dataFolder = new File("SkyBlock.db");
- if (!dataFolder.exists()){
- try {
- dataFolder.createNewFile();
- } catch (IOException e) {}
- }
- try {
- if(connection != null && !connection.isClosed()){
- return connection;
- }
- Class.forName("org.sqlite.JDBC");
- connection = DriverManager.getConnection("jdbc:sqlite:SkyBlock.db");
- return connection;
- } catch (SQLException ex) {} catch (ClassNotFoundException ex) {}
- return null;
- }
- public static boolean isConnected(){
- return (connection == null ? false : true);
- }
- public static void disconnect(){
- if(isConnected()){
- try{
- connection.close();
- }catch(SQLException e){
- }
- }
- }
- public static void load() {
- connection = getSQLConnection();
- try {
- Statement s = connection.createStatement();
- s.executeUpdate(SQLiteCreateTokensTable);
- s.close();
- } catch (SQLException e) {}
- }
- public static void update(String qry) {
- try {
- Statement st = connection.createStatement();
- st.executeUpdate(qry);
- st.close();
- } catch (SQLException e) {
- getSQLConnection();
- }
- }
- public static ResultSet query(String qry) {
- ResultSet rs = null;
- try {
- Statement st = connection.createStatement();
- rs = st.executeQuery(qry);
- } catch (SQLException e) {
- getSQLConnection();
- }
- return rs;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement