Class MySqlDatabase

java.lang.Object
de.oliver.fancylib.databases.MySqlDatabase
All Implemented Interfaces:
Database
Direct Known Subclasses:
SqliteDatabase

public class MySqlDatabase extends Object implements Database
  • Field Details

    • host

      protected final String host
    • port

      protected final String port
    • database

      protected final String database
    • username

      protected final String username
    • password

      protected final String password
    • connection

      protected Connection connection
  • Constructor Details

  • Method Details

    • connect

      public boolean connect()
      Description copied from interface: Database
      Connects to the database
      Specified by:
      connect in interface Database
      Returns:
      true if success, false if failed
    • close

      public boolean close()
      Description copied from interface: Database
      Closes the database connection
      Specified by:
      close in interface Database
      Returns:
      true if success, false if failed
    • isConnected

      public boolean isConnected()
      Specified by:
      isConnected in interface Database
      Returns:
      true if connected, false if not
    • getConnection

      public Connection getConnection()
      Specified by:
      getConnection in interface Database
      Returns:
      the connection object, null if not connected
    • executeNonQuery

      public boolean executeNonQuery(String sql)
      Description copied from interface: Database
      Executes a statement on the database
      Specified by:
      executeNonQuery in interface Database
      Returns:
      true if success, false if failed
    • executeQuery

      public ResultSet executeQuery(String query)
      Description copied from interface: Database
      Executes a query on the database
      Specified by:
      executeQuery in interface Database
      Returns:
      the result or null if failed