Package org.apache.torque.adapter

## Class MysqlAdapter

- java.lang.Object
- - org.apache.torque.adapter.AbstractAdapter
  - - org.apache.torque.adapter.MysqlAdapter

- All Implemented Interfaces:
    `Serializable`, `Adapter`

      public class MysqlAdapter
      extends AbstractAdapter

  This is used in order to connect to a MySQL database using the MM drivers. Simply comment the above and uncomment this code below and fill in the appropriate values for DB_NAME, DB_HOST, DB_USER, DB_PASS.

  http://www.mysql.com/

  "jdbc:mysql://" + DB_HOST + "/" + DB_NAME + "?user=" + DB_USER + "&password=" + DB_PASS;

  Version:
    $Id: MysqlAdapter.java 1850965 2019-01-10 17:21:29Z painter $
  Author:
    Jon S. Stevens, Brett McLaughlin, Daniel Rall
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface org.apache.torque.adapter.Adapter

      `ADAPTER_KEY, AUTODETECT_ADAPTER, DRIVER_KEY`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `MysqlAdapter()` | Empty protected constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `generateLimits​(Query query, long offset, int limit)` | Generate a LIMIT offset, limit clause if offset > 0 or an LIMIT limit clause if limit is > 0 and offset is 0.
    `String` | `getIDMethodSQL​(Object obj)` | Returns the SQL to get the database key of the last row inserted, which in this case is `SELECT LAST_INSERT_ID()`.
    `IDMethod` | `getIDMethodType()` | Returns the constant from the `IDMethod` interface denoting which type of primary key generation method this type of RDBMS uses.
    `String` | `ignoreCase​(String in)` | This method is used to ignore case.
    `void` | `lockTable​(Connection con, String table)` | Locks the specified table.
    `String` | `toUpperCase​(String in)` | This method is used to ignore case.
    `void` | `unlockTable​(Connection con, String table)` | Unlocks the specified table.

    - ### Methods inherited from class org.apache.torque.adapter.AbstractAdapter

      `escapeText, getStringDelimiter, getUpdateLockClause, ignoreCaseInOrderBy, setCapabilities, supportsNativeLimit, supportsNativeOffset, useEscapeClauseForLike, useGetGeneratedKeys, useIlike, useMinusForExcept`

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

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

- - ### Constructor Detail

    - #### MysqlAdapter

          protected MysqlAdapter()

      Empty protected constructor.

  - ### Method Detail

    - #### toUpperCase

          public String toUpperCase​(String in)

      This method is used to ignore case.
      Specified by:
        `toUpperCase` in interface `Adapter`
      Specified by:
        `toUpperCase` in class `AbstractAdapter`
      Parameters:
        `in` - The string to transform to upper case.
      Returns:
        The upper case string.

    - #### ignoreCase

          public String ignoreCase​(String in)

      This method is used to ignore case.
      Specified by:
        `ignoreCase` in interface `Adapter`
      Specified by:
        `ignoreCase` in class `AbstractAdapter`
      Parameters:
        `in` - The string whose case to ignore.
      Returns:
        The string in a case that can be ignored.

    - #### getIDMethodType

          public IDMethod getIDMethodType()

      Description copied from class: `AbstractAdapter`
      Returns the constant from the `IDMethod` interface denoting which type of primary key generation method this type of RDBMS uses.
      Specified by:
        `getIDMethodType` in interface `Adapter`
      Specified by:
        `getIDMethodType` in class `AbstractAdapter`
      Returns:
        IDMethod constant
      See Also:
        `Adapter.getIDMethodType()`

    - #### getIDMethodSQL

          public String getIDMethodSQL​(Object obj)

      Returns the SQL to get the database key of the last row inserted, which in this case is `SELECT LAST_INSERT_ID()`.
      Specified by:
        `getIDMethodSQL` in interface `Adapter`
      Specified by:
        `getIDMethodSQL` in class `AbstractAdapter`
      Parameters:
        `obj` - Information used for key generation.
      Returns:
        The most recently inserted database key.
      See Also:
        `Adapter.getIDMethodSQL(Object obj)`

    - #### lockTable

          public void lockTable​(Connection con,
                                String table)
                         throws SQLException

      Locks the specified table.
      Specified by:
        `lockTable` in interface `Adapter`
      Specified by:
        `lockTable` in class `AbstractAdapter`
      Parameters:
        `con` - The JDBC connection to use.
        `table` - The name of the table to lock.
      Throws:
        `SQLException` - No Statement could be created or executed.

    - #### unlockTable

          public void unlockTable​(Connection con,
                                  String table)
                           throws SQLException

      Unlocks the specified table.
      Specified by:
        `unlockTable` in interface `Adapter`
      Specified by:
        `unlockTable` in class `AbstractAdapter`
      Parameters:
        `con` - The JDBC connection to use.
        `table` - The name of the table to unlock.
      Throws:
        `SQLException` - No Statement could be created or executed.

    - #### generateLimits

          public void generateLimits​(Query query,
                                     long offset,
                                     int limit)

      Generate a LIMIT offset, limit clause if offset > 0 or an LIMIT limit clause if limit is > 0 and offset is 0.
      Specified by:
        `generateLimits` in interface `Adapter`
      Overrides:
        `generateLimits` in class `AbstractAdapter`
      Parameters:
        `query` - The query to modify
        `offset` - the offset Value
        `limit` - the limit Value