com.intellectualcrafters.plot.database

## Class Database

- java.lang.Object
- - com.intellectualcrafters.plot.database.Database

- Direct Known Subclasses:
    MySQL, SQLite

      public abstract class Database
      extends java.lang.Object

  Abstract Database class, serves as a base for any connection method (MySQL, SQLite, etc.)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.bukkit.plugin.Plugin` | `plugin` Plugin instance, use for plugin.getDataFolder()

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Database(org.bukkit.plugin.Plugin plugin)` Creates a new Database

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract boolean` | `checkConnection()` Checks if a connection is open with the database
    `abstract boolean` | `closeConnection()` Closes the connection with the database
    `abstract java.sql.Connection` | `getConnection()` Gets the connection with the database
    `abstract java.sql.Connection` | `openConnection()` Opens a connection with the database
    `abstract java.sql.ResultSet` | `querySQL(java.lang.String query)` Executes a SQL Query If the connection is closed, it will be opened
    `abstract int` | `updateSQL(java.lang.String query)` Executes an Update SQL Query See `Statement.executeUpdate(String)` If the connection is closed, it will be opened

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### plugin

          protected org.bukkit.plugin.Plugin plugin

      Plugin instance, use for plugin.getDataFolder()

  - ### Constructor Detail

    - #### Database

          protected Database(org.bukkit.plugin.Plugin plugin)

      Creates a new Database
      Parameters:
        `plugin` - Plugin instance

  - ### Method Detail

    - #### openConnection

          public abstract java.sql.Connection openConnection()
                                                      throws java.sql.SQLException,
                                                             java.lang.ClassNotFoundException

      Opens a connection with the database
      Returns:
        Opened connection
      Throws:
        `java.sql.SQLException` - if the connection can not be opened
        `java.lang.ClassNotFoundException` - if the driver cannot be found

    - #### checkConnection

          public abstract boolean checkConnection()
                                           throws java.sql.SQLException

      Checks if a connection is open with the database
      Returns:
        true if the connection is open
      Throws:
        `java.sql.SQLException` - if the connection cannot be checked

    - #### getConnection

          public abstract java.sql.Connection getConnection()

      Gets the connection with the database
      Returns:
        Connection with the database, null if none

    - #### closeConnection

          public abstract boolean closeConnection()
                                           throws java.sql.SQLException

      Closes the connection with the database
      Returns:
        true if successful
      Throws:
        `java.sql.SQLException` - if the connection cannot be closed

    - #### querySQL

          public abstract java.sql.ResultSet querySQL(java.lang.String query)
                                               throws java.sql.SQLException,
                                                      java.lang.ClassNotFoundException

      Executes a SQL Query
      If the connection is closed, it will be opened
      Parameters:
        `query` - Query to be run
      Returns:
        the results of the query
      Throws:
        `java.sql.SQLException` - If the query cannot be executed
        `java.lang.ClassNotFoundException` - If the driver cannot be found; see `openConnection()`

    - #### updateSQL

          public abstract int updateSQL(java.lang.String query)
                                 throws java.sql.SQLException,
                                        java.lang.ClassNotFoundException

      Executes an Update SQL Query
      See `Statement.executeUpdate(String)`
      If the connection is closed, it will be opened
      Parameters:
        `query` - Query to be run
      Returns:
        Result Code, see `Statement.executeUpdate(String)`
      Throws:
        `java.sql.SQLException` - If the query cannot be executed
        `java.lang.ClassNotFoundException` - If the driver cannot be found; see `openConnection()`