Class Transaction

  • Direct Known Subclasses:
    MultiPluginTransaction

    public class Transaction
    extends java.lang.Object
    Transaction
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int COMMITTED
      Status for committed transactions
      static int OPENED
      Status for opened transactions
      static int ROLLEDBACK
      Status for roll backed transactions
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void commit()
      Commit the transaction
      void executeStatement()
      Execute the current statement
      java.sql.PreparedStatement getStatement()
      The current prepared statement
      int getStatus()
      Return the transaction status
      java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL)
      Gets a prepared statement
      java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL, boolean bLogQueries)
      Gets a prepared statement
      java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL, java.lang.Integer autoGeneratedKeys)
      Gets a prepared statement
      java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL, java.lang.Integer autoGeneratedKeys, boolean bLogQueries)
      Gets a prepared statement
      void rollback()
      Rollback the transaction
      void rollback​(java.lang.Exception e)
      Rollback the transaction
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COMMITTED

        public static final int COMMITTED
        Status for committed transactions
        See Also:
        Constant Field Values
      • ROLLEDBACK

        public static final int ROLLEDBACK
        Status for roll backed transactions
        See Also:
        Constant Field Values
    • Constructor Detail

      • Transaction

        public Transaction()
        Constructor
      • Transaction

        public Transaction​(Plugin plugin)
        Constructor
        Parameters:
        plugin - The plugin owner of the transaction
    • Method Detail

      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL)
                                                    throws java.sql.SQLException
        Gets a prepared statement
        Parameters:
        strSQL - The SQL statement
        Returns:
        The prepared statement
        Throws:
        java.sql.SQLException - If an SQL error occurs
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL,
                                                           java.lang.Integer autoGeneratedKeys)
                                                    throws java.sql.SQLException
        Gets a prepared statement
        Parameters:
        strSQL - The SQL statement
        Returns:
        The prepared statement
        Throws:
        java.sql.SQLException - If an SQL error occurs
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL,
                                                           boolean bLogQueries)
                                                    throws java.sql.SQLException
        Gets a prepared statement
        Parameters:
        strSQL - The SQL statement
        Returns:
        The prepared statement
        Throws:
        java.sql.SQLException - If an SQL error occurs
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String strSQL,
                                                           java.lang.Integer autoGeneratedKeys,
                                                           boolean bLogQueries)
                                                    throws java.sql.SQLException
        Gets a prepared statement
        Parameters:
        strSQL - The SQL statement
        autoGeneratedKeys - a flag indicating whether auto-generated keys should be returned; For example one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS. See PreparedStatement#prepareStatement(String, int)
        Returns:
        The prepared statement
        Throws:
        java.sql.SQLException - If an SQL error occurs
        Since:
        6.0.0
      • getStatement

        public java.sql.PreparedStatement getStatement()
        The current prepared statement
        Returns:
        The current statement
      • executeStatement

        public void executeStatement()
                              throws java.sql.SQLException
        Execute the current statement
        Throws:
        java.sql.SQLException - If an SQL error occurs
      • commit

        public void commit()
        Commit the transaction
      • rollback

        public void rollback()
        Rollback the transaction
      • rollback

        public void rollback​(java.lang.Exception e)
        Rollback the transaction
        Parameters:
        e - The exception that cause the rollback
      • getStatus

        public int getStatus()
        Return the transaction status
        Returns:
        The transaction status