Holger's Java API

## com.antelmann.sql
Class MySQLHelper

    java.lang.Object
      com.antelmann.sql.ConnectionHelper
          com.antelmann.sql.MySQLHelper

All Implemented Interfaces:
  Wrapped<Connection>

    @ThirdParty(value="MySQL JDBC driver: com.mysql.jdbc")
    public class MySQLHelper

extends ConnectionHelper

provides added functionality for MySQL database

Since:
  30.08.2012, 11:14:04
Author:
  Holger Antelmann
See Also:
  `Mysqldump`, `MySQLLog`

Constructor Summary
`MySQLHelper(Connection con)`

Method Summary
`static Logger` `configureAndGetLogger(Connector c)`
`static Connector` `configureLogger(Connector c, Class<? extends com.mysql.jdbc.log.Log> logClass)` allows to configure the given Connector so that all calls are traced by the given loggerClass
`static Connector` `configureProfiler(Connector c, Class<? extends com.mysql.jdbc.profiler.ProfilerEventHandler> loggerClass)` allows to configure the given Connector so that all calls are traced by the given loggerClass
`static Connector` `configureSlowQueries(Connector c, long millis)`
`void` `copyTable(String source, String newTable)`
`void` `export(String table, File file)`
`com.mysql.jdbc.Connection` `getConnection()`
`static com.mysql.jdbc.profiler.ProfilerEventHandler` `getProfileEventHandler(Connection con)`
`String` `getSessionVariable(String variable)`
`HashMap<String,String>` `getSessionVariables()`
`String` `getSqlForView(String viewName)`
`boolean` `isMySQL()`
`void` `lockTable(boolean exclusive, String... tables)` useful for early requiring locks to avoid deadlocks
`void` `setSessionVariable(String variable, String value)`
`void` `setStreamResults(boolean flag)` setting this flag to true will set the fetch size to `Integer.MIN_VALUE`.
`void` `setWaitTimeout(int timeout)`

Methods inherited from class com.antelmann.sql.ConnectionHelper

`addIndex, addOrderBy, addPrimaryIndex, addWhereClause, addWhereClause, addWhereClause, addWhereClauseOnSearchPattern, addWhereClauseOnSearchPattern, contains, contains, convertDateRangeToSQL, convertTimestampRangeToSQL, copyIndices, copyPrimaryKey, copyTable, copyTable, copyTo, countDistinctValues, createTableString, delete, deleteRow, deleteRows, dropIndex, escape, escape, executeUpdate, exportAsCSV, exportAsCSV, exportAsCSV, exportAsCSV, extractRow, extractRowItem, extractRows, filterTable, filterTable, filterTable, filterTable, filterTable, filterTable, filterTableForText, filterTableForText, filterTableForText, filterTableScrollable, filterTableUpdateable, findDuplicates, findInTable, getAggregatedFunctionValue, getAggregatedFunctionValue, getAverageValue, getColumnNames, getCommonColumns, getCount, getCount, getDateFormat, getDBType, getDistinctValues, getDistinctValues, getDistinctValuesWithCount, getDistinctValuesWithCount, getFetchSize, getFirstRowFor, getForeignKeysModel, getForeingKeys, getFunctionValue, getFunctionValue, getFunctionValue, getFunctionValue, getIndicesForTable, getMaxTextLength, getMaxValue, getMetaDataAsTableModel, getMinValue, getPrimaryKeysForTable, getReservedWords, getResultSet, getResultSet, getRow, getRowItem, getRowItems, getRowItems, getRowItems, getRowItems, getRowItems, getSumValue, getTable, getTableModel, getTableNames, getTypeNameFor, getValue, getViews, importTableModel, insert, insertRow, insertRow, insertRow, insertRowWithGeneratedKeys, insertTableModel, isCharType, isDateType, isMSAccess, isNumberType, isSelect, isSQLServer, iterate, javaToSql, loadAsMap, loadTable, loadTable, mapColumnNamesToDisplayNames, mapColumnNamesToSize, mapColumnNamesToSize, mapColumnNamesToSize, mapColumnNamesToSQLTypes, mapColumnNamesToSQLTypes, mapColumnNamesToTypeString, mapColumnNamesToTypeString, needsSelect, processColumn, queryDuplicates, replace, searchDatabaseFor, searchDuplicates, setDateFormat, setDoNotEscapeNames, setEscapeChars, setFetchSize, sqlToJava, transferTable, trimToLastDot, unwrap, update, update, update, updateRows, updateRows, updateRows, updateTable`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### MySQLHelper

    public MySQLHelper(Connection con)

Method Detail

### isMySQL

    public boolean isMySQL()

  Overrides:
    `isMySQL` in class `ConnectionHelper`

### getConnection

    public com.mysql.jdbc.Connection getConnection()

  Overrides:
    `getConnection` in class `ConnectionHelper`

### setWaitTimeout

    public void setWaitTimeout(int timeout)
                        throws SQLException

  Parameters:
    `timeout` - number of seconds
  Throws:
    `SQLException`

### lockTable

    @Todo(value="still problems w/ intrusiveness & transactions")
    public void lockTable(boolean exclusive,
                                    String... tables)
                   throws SQLException

  Description copied from class: `ConnectionHelper`
  useful for early requiring locks to avoid deadlocks

  Overrides:
    `lockTable` in class `ConnectionHelper`
  Throws:
    `SQLException`

### setStreamResults

    public void setStreamResults(boolean flag)

  setting this flag to true will set the fetch size to `Integer.MIN_VALUE`. This is the only value other than 0 that will make MySQL react so that it will stream the results instead of loading the entire ResultSet; if the flag is false, 0 will be set. Note that if this is set to true, no other query can be done on the connection until the underlying statement of a streamed ResultSet is closed again!

### setSessionVariable

    @Warning(value="be aware of SQL-Injection here as PreparedStatement parameters won\'t work")
    public void setSessionVariable(String variable,
                                                String value)
                            throws SQLException

  Throws:
    `SQLException`

### getSessionVariable

    public String getSessionVariable(String variable)
                              throws SQLException

  Throws:
    `SQLException`

### getSessionVariables

    public HashMap<String,String> getSessionVariables()
                                               throws SQLException

  Throws:
    `SQLException`

### copyTable

    public void copyTable(String source,
                          String newTable)
                   throws SQLException

  Throws:
    `SQLException`

### export

    public void export(String table,
                       File file)
                throws SQLException

  Throws:
    `SQLException`

### getSqlForView

    public String getSqlForView(String viewName)
                         throws SQLException

  Throws:
    `SQLException`

### configureSlowQueries

    public static Connector configureSlowQueries(Connector c,
                                                 long millis)

### getProfileEventHandler

    public static com.mysql.jdbc.profiler.ProfilerEventHandler getProfileEventHandler(Connection con)

### configureProfiler

    public static Connector configureProfiler(Connector c,
                                              Class<? extends com.mysql.jdbc.profiler.ProfilerEventHandler> loggerClass)

  allows to configure the given Connector so that all calls are traced by the given loggerClass

  See Also:
    `getProfileEventHandler(Connection)`, `MySQLLog`

### configureLogger

    public static Connector configureLogger(Connector c,
                                            Class<? extends com.mysql.jdbc.log.Log> logClass)

  allows to configure the given Connector so that all calls are traced by the given loggerClass

  See Also:
    `Connection.getLog()`, `MySQLLog`

### configureAndGetLogger

    public static Logger configureAndGetLogger(Connector c)

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads