Class Database.Connection

  • Enclosing class:
    Database

    public final class Database.Connection
    extends java.lang.Object
    The object that stores tasks related to the connection, use Database.getConnection() to access methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      Connection()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void connect()
      Connects to the database and shows a retry dialog message box if the connection fails.
      void connect​(boolean showStatusAlert, boolean showRetryDialog)
      Connects to the database and if parameter is true, shows a message box if the connection succeeds.
      void disconnect()
      Releases this database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed, It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources, shows message box on error.
      boolean equals​(java.lang.Object o)  
      java.sql.Connection getObject()
      Returns the raw java.sql.Connection object.
      int hashCode()  
      boolean isConnected()
      Checks if a connection is open to the database.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Connection

        public Connection()
    • Method Detail

      • getObject

        public java.sql.Connection getObject()
        Returns the raw java.sql.Connection object.
        Returns:
        the Connection object
      • connect

        public void connect()
                     throws java.sql.SQLException
        Connects to the database and shows a retry dialog message box if the connection fails.
        Throws:
        java.sql.SQLException - if error occurs
      • connect

        public void connect​(boolean showStatusAlert,
                            boolean showRetryDialog)
                     throws java.sql.SQLException
        Connects to the database and if parameter is true, shows a message box if the connection succeeds.
        Parameters:
        showStatusAlert - Specifies if message box should be shown if connection succeeds
        showRetryDialog - Specifies if a retry dialog should be shown if the database is in use
        Throws:
        java.sql.SQLException - if error occurs
      • disconnect

        public void disconnect()
                        throws java.sql.SQLException
        Releases this database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed, It is generally good practice to release resources as soon as you are finished with them to avoid tying up database resources, shows message box on error.
        Throws:
        java.sql.SQLException - if error occurs
      • isConnected

        public boolean isConnected()
                            throws java.sql.SQLException
        Checks if a connection is open to the database.
        Returns:
        true if connected
        Throws:
        java.sql.SQLException - if error occurs
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object