psdi.mbo

Class DBShortcut

  • java.lang.Object
    • psdi.mbo.DBShortcut
  • All Implemented Interfaces:
    FixedLoggerNames, FixedLoggers


    public class DBShortcut
    extends java.lang.Object
    implements FixedLoggers
    The DBShortcut is a shortcut class to allow direct access to the database. When performance becomes one of the biggest concerns. Sometime, it is necessary to bypass the mbo set restriction in order to speed up the database access.
    • Field Detail

      • UPDATE

        public int UPDATE
        Sql statement type: update.
      • QUERY

        public int QUERY
        Sql statment type: Query.
      • ANY

        public int ANY
        Other sql statment types.
    • Constructor Detail

      • DBShortcut

        public DBShortcut()
        Default constructor. Currently doing nothing.
    • Method Detail

      • connect

        public void connect(ConnectionKey conKey)
                     throws java.rmi.RemoteException,
                            MXApplicationException
        This method obtains a SQL.Connection to the database connected by MXServer The returned connection is obtained by MXserver. The object passed in as parameter acts as a key for the connection. The same connection will be returned if the key is the same. You must call close() when you finish use this connection. Everytime this function is called, the DBShortcut object's connection is updated.
        Parameters:
        key - The object acts as a key for MXServer when it looks for the connection. If you pass the same key everytime, you will get the same connection.
        Throws:
        java.rmi.RemoteException
        MXApplicationException
        See Also:
        DBShortcut.close()
      • execute

        public void execute(int type,
                            SqlFormat sqlStat)
                     throws MXException
        Executes the SQL statement. According to the integer represents different type os SQL statement, different sql execution functions provided in java.sql.Connection.Statement will be called. executeUpdate() for UPDATE, executeQuery() for QUERY, execute() for any other types. Commit is not called.
        Parameters:
        type - The type of SQL statement. UPDATE: insert, update type of sql statement; QUERY: query statement; ANY: all the other types, or if you don't care about the types.
        sqlStat - The sql statement to be executed.
        Throws:
        java.rmi.RemoteException
        MXException
        See Also:
        DBShortcut.execute(psdi.mbo.SqlFormat)
      • execute

        public void execute(SqlFormat sqlStat)
                     throws MXException
        Executes the SQL statement specified in SqlFormat parameter. It calls java.sql.connection.Execute function. Commit is not called.
        Parameters:
        sqlStat - SqlFormat object which contains a sql statement string to be executed.
        Throws:
        java.rmi.RemoteException
        MXException
        See Also:
        DBShortcut.execute(int, psdi.mbo.SqlFormat)
      • commit

        public void commit()
                    throws java.sql.SQLException
        Commit all the SQL statement execution after the prior commit is called.
        Throws:
        java.sql.SQLException
      • close

        public void close()
        Close the connection. Ask MXServer to release the resources.
        Throws:
        java.sql.SQLException
        java.rmi.RemoteException
      • rollBack

        public void rollBack()
                      throws java.sql.SQLException
        Roll back the sql statements.
        Throws:
        java.sql.SQLException
      • executeQuery

        public java.sql.ResultSet executeQuery(java.lang.String sqlStat)
        Executes a SQL query and returns the result set. commit() is not called. close() will have to be called
        Parameters:
        sqlStat - The sql statement to be executed.
        Throws:
        java.rmi.RemoteException
        See Also:
        DBShortcut.execute(psdi.mbo.SqlFormat)