Connector/J JDBC Driver Connection Properties - Part 2
What is connection properties are supported by Connector/J JDBC Driver?
What are their default property values?
Connection properties supported by Connector/J JDBC driver and property default values
are listed below:
- ... Continue from Part 1
- useUsageAdvisor - Should the driver issue 'usage' warnings advising proper and efficient usage of JDBC and MySQL Connector/J to the log (true/false, defaults to 'false')? Default: false
- autoGenerateTestcaseScript - Should the driver dump the SQL it is executing, including server-side prepared statements to STDERR? Default: false
- autoSlowLog - Instead of using slowQueryThreshold* to determine if a query is slow enough to be logged, maintain statistics that allow the driver to determine queries that are outside the 99th percentile? Default: true
- clientInfoProvider - The name of a class that implements the com.mysql.jdbc.JDBC4ClientInfoProvider interface in order to support JDBC-4.0's Connection.get/setClientInfo() methods Default: com.mysql.jdbc.JDBC4CommentClientInfoProvider
- dumpMetadataOnColumnNotFound - Should the driver dump the field-level metadata of a result set into the exception message when ResultSet.findColumn() fails? Default: false
- dumpQueriesOnException - Should the driver dump the contents of the query sent to the server in the message for SQLExceptions? Default: false
- enablePacketDebug - When enabled, a ring-buffer of 'packetDebugBufferSize' packets will be kept, and dumped when exceptions are thrown in key areas in the driver's code Default: false
- explainSlowQueries - If 'logSlowQueries' is enabled, should the driver automatically issue an 'EXPLAIN' on the server and send the results to the configured log at a WARN level? Default: false
- includeInnodbStatusInDeadlockExceptions - Include the output of "SHOW ENGINE INNODB STATUS" in exception messages when deadlock exceptions are detected? Default: false
- includeThreadDumpInDeadlockExceptions - Include a current Java thread dump in exception messages when deadlock exceptions are detected? Default: false
- includeThreadNamesAsStatementComment - Include the name of the current thread as a comment visible in "SHOW PROCESSLIST", or in Innodb deadlock dumps, useful in correlation with "includeInnodbStatusInDeadlockExceptions=true" and "includeThreadDumpInDeadlockExceptions=true". Default: false
- logSlowQueries - Should queries that take longer than 'slowQueryThresholdMillis' be logged? Default: false
- logXaCommands - Should the driver log XA commands sent by MysqlXaConnection to the server, at the DEBUG level of logging? Default: false
- profilerEventHandler - Name of a class that implements the interface com.mysql.jdbc.profiler.ProfilerEventHandler that will be used to handle profiling/tracing events. Default: com.mysql.jdbc.profiler.LoggingProfilerEventHandler
- resultSetSizeThreshold - If the usage advisor is enabled, how many rows should a result set contain before the driver warns that it is suspiciously large? Default: 100
- traceProtocol - Should trace-level network protocol be logged? Default: false
- useNanosForElapsedTime - For profiling/debugging functionality that measures elapsed time, should the driver try to use nanoseconds resolution if available (JDK >= 1.5)? Default: false
- useUnicode - Should the driver use Unicode character encodings when handling strings? Should only be used when the driver can't determine the character set mapping, or you are trying to 'force' the driver to use a character set that MySQL either doesn't natively support (such as UTF-8), true/false, defaults to 'true' Default: true
- characterEncoding - If 'useUnicode' is set to true, what character encoding should the driver use when dealing with strings? (defaults is to 'autodetect')
- characterSetResults - Character set to tell the server to return results as.
- connectionAttributes - A comma-delimited list of user-defined key:value pairs (in addition to standard MySQL-defined key:value pairs) to be passed to MySQL Server for display as connection attributes in the PERFORMANCE_SCHEMA.SESSION_CONNECT_ATTRS table.
- connectionCollation - If set, tells the server to use this collation via 'set collation_connection'
- useBlobToStoreUTF8OutsideBMP - Tells the driver to treat [MEDIUM/LONG]BLOB columns as [LONG]VARCHAR columns holding text encoded in UTF-8 that has characters outside the BMP (4-byte encodings), which MySQL server can't handle natively. Default: false
- utf8OutsideBmpExcludedColumnNamePattern - When "useBlobToStoreUTF8OutsideBMP" is set to "true", column names matching the given regex will still be treated as BLOBs unless they match the regex specified for "utf8OutsideBmpIncludedColumnNamePattern". The regex must follow the patterns used for the java.util.regex package.
- utf8OutsideBmpIncludedColumnNamePattern - Used to specify exclusion rules to "utf8OutsideBmpExcludedColumnNamePattern". The regex must follow the patterns used for the java.util.regex package.
- loadBalanceEnableJMX - Enables JMX-based management of load-balanced connection groups, including live addition/removal of hosts from load-balancing pool. Default: false
- loadBalanceHostRemovalGracePeriod - Sets the grace period to wait for a host being removed from a load-balanced connection, to be released when it is currently the active host. Default: 15000
- sessionVariables - A comma-separated list of name/value pairs to be sent as SET SESSION ... to the server when the driver connects.
- useColumnNamesInFindColumn - Prior to JDBC-4.0, the JDBC specification had a bug related to what could be given as a "column name" to ResultSet methods like findColumn(), or getters that took a String property. JDBC-4.0 clarified "column name" to mean the label, as given in an "AS" clause and returned by ResultSetMetaData.getColumnLabel(), and if no AS clause, the column name. Setting this property to "true" will give behavior that is congruent to JDBC-3.0 and earlier versions of the JDBC specification, but which because of the specification bug could give unexpected results. This property is preferred over "useOldAliasMetadataBehavior" unless you need the specific behavior that it provides with respect to ResultSetMetadata. Default: false
- allowNanAndInf - Should the driver allow NaN or +/- INF values in PreparedStatement.setDouble()? Default: false
- autoClosePStmtStreams - Should the driver automatically call .close() on streams/readers passed as arguments via set*() methods? Default: false
- autoDeserialize - Should the driver automatically detect and de-serialize objects stored in BLOB fields? Default: false
- blobsAreStrings - Should the driver always treat BLOBs as Strings - specifically to work around dubious metadata returned by the server for GROUP BY clauses? Default: false
- cacheDefaultTimezone - Caches client's default time zone. This results in better performance when dealing with time zone conversions in Date and Time data types, however it won't be aware of time zone changes if they happen at runtime. Default: true
- capitalizeTypeNames - Capitalize type names in DatabaseMetaData? (usually only useful when using WebObjects, true/false, defaults to 'false') Default: true
- clobCharacterEncoding - The character encoding to use for sending and retrieving TEXT, MEDIUMTEXT and LONGTEXT values instead of the configured connection characterEncoding
- clobberStreamingResults - This will cause a 'streaming' ResultSet to be automatically closed, and any outstanding data still streaming from the server to be discarded if another query is executed before all the data has been read from the server. Default: false
- compensateOnDuplicateKeyUpdateCounts - Should the driver compensate for the update counts of "ON DUPLICATE KEY" INSERT statements (2 = 1, 0 = 1) when using prepared statements? Default: false
- continueBatchOnError - Should the driver continue processing batch commands if one statement fails. The JDBC spec allows either way (defaults to 'true'). Default: true
- createDatabaseIfNotExist - Creates the database given in the URL if it doesn't yet exist. Assumes the configured user has permissions to create databases. Default: false
- detectCustomCollations - Should the driver detect custom charsets/collations installed on server (true/false, defaults to 'false'). If this option set to 'true' driver gets actual charsets/collations from server each time connection establishes. This could slow down connection initialization significantly. Default: false
- emptyStringsConvertToZero - Should the driver allow conversions from empty string fields to numeric values of '0'? Default: true
- emulateLocators - Should the driver emulate java.sql.Blobs with locators? With this feature enabled, the driver will delay loading the actual Blob data until the one of the retrieval methods (getInputStream(), getBytes(), and so forth) on the blob data stream has been accessed. For this to work, you must use a column alias with the value of the column to the actual name of the Blob. The feature also has the following restrictions: The SELECT that created the result set must reference only one table, the table must have a primary key; the SELECT must alias the original blob column name, specified as a string, to an alternate name; the SELECT must cover all columns that make up the primary key. Default: false
- emulateUnsupportedPstmts - Should the driver detect prepared statements that are not supported by the server, and replace them with client-side emulated versions? Default: true
- exceptionInterceptors - Comma-delimited list of classes that implement com.mysql.jdbc.ExceptionInterceptor. These classes will be instantiated one per Connection instance, and all SQLExceptions thrown by the driver will be allowed to be intercepted by these interceptors, in a chained fashion, with the first class listed as the head of the chain.
- functionsNeverReturnBlobs - Should the driver always treat data from functions returning BLOBs as Strings - specifically to work around dubious metadata returned by the server for GROUP BY clauses? Default: false
- generateSimpleParameterMetadata - Should the driver generate simplified parameter metadata for PreparedStatements when no metadata is available either because the server couldn't support preparing the statement, or server-side prepared statements are disabled? Default: false
- getProceduresReturnsFunctions - Pre-JDBC4 DatabaseMetaData API has only the getProcedures() and getProcedureColumns() methods, so they return metadata info for both stored procedures and functions. JDBC4 was extended with the getFunctions() and getFunctionColumns() methods and the expected behaviours of previous methods are not well defined. For JDBC4 and higher, default 'true' value of the option means that calls of DatabaseMetaData.getProcedures() and DatabaseMetaData.getProcedureColumns() return metadata for both procedures and functions as before, keeping backward compatibility. Setting this property to 'false' decouples Connector/J from its pre-JDBC4 behaviours for DatabaseMetaData.getProcedures() and DatabaseMetaData.getProcedureColumns(), forcing them to return metadata for procedures only. Default: true
- ignoreNonTxTables - Ignore non-transactional table warning for rollback? (defaults to 'false'). Default: false
- jdbcCompliantTruncation - Should the driver throw java.sql.DataTruncation exceptions when data is truncated as is required by the JDBC specification when connected to a server that supports warnings (MySQL 4.1.0 and newer)? This property has no effect if the server sql-mode includes STRICT_TRANS_TABLES. Default: true
- loadBalanceAutoCommitStatementRegex - When load-balancing is enabled for auto-commit statements (via loadBalanceAutoCommitStatementThreshold), the statement counter will only increment when the SQL matches the regular expression. By default, every statement issued matches.
- loadBalanceAutoCommitStatementThreshold - When auto-commit is enabled, the number of statements which should be executed before triggering load-balancing to rebalance. Default value of 0 causes load-balanced connections to only rebalance when exceptions are encountered, or auto-commit is disabled and transactions are explicitly committed or rolled back. Default: 0
- loadBalanceBlacklistTimeout - Time in milliseconds between checks of servers which are unavailable, by controlling how long a server lives in the global blacklist. Default: 0
- loadBalanceConnectionGroup - Logical group of load-balanced connections within a classloader, used to manage different groups independently. If not specified, live management of load-balanced connections is disabled.
- loadBalanceExceptionChecker - Fully-qualified class name of custom exception checker. The class must implement com.mysql.jdbc.LoadBalanceExceptionChecker interface, and is used to inspect SQLExceptions and determine whether they should trigger fail-over to another host in a load-balanced deployment. Default: com.mysql.jdbc.StandardLoadBalanceExceptionChecker
- loadBalancePingTimeout - Time in milliseconds to wait for ping response from each of load-balanced physical connections when using load-balanced Connection. Default: 0
- loadBalanceSQLExceptionSubclassFailover - Comma-delimited list of classes/interfaces used by default load-balanced exception checker to determine whether a given SQLException should trigger failover. The comparison is done using Class.isInstance(SQLException) using the thrown SQLException.
- loadBalanceSQLStateFailover - Comma-delimited list of SQLState codes used by default load-balanced exception checker to determine whether a given SQLException should trigger failover. The SQLState of a given SQLException is evaluated to determine whether it begins with any value in the comma-delimited list.
- loadBalanceValidateConnectionOnSwapServer - Should the load-balanced Connection explicitly check whether the connection is live when swapping to a new physical connection at commit/rollback? Default: false
- maxRows - The maximum number of rows to return (0, the default means return all rows). Default: -1
- netTimeoutForStreamingResults - What value should the driver automatically set the server setting 'net_write_timeout' to when the streaming result sets feature is in use? (value has unit of seconds, the value '0' means the driver will not try and adjust this value) Default: 600
- noAccessToProcedureBodies - When determining procedure parameter types for CallableStatements, and the connected user can't access procedure bodies through "SHOW CREATE PROCEDURE" or select on mysql.proc should the driver instead create basic metadata (all parameters reported as IN VARCHARs, but allowing registerOutParameter() to be called on them anyway) instead of throwing an exception? Default: false
- noDatetimeStringSync - Don't ensure that ResultSet.getDatetimeType().toString().equals(ResultSet.getString()) Default: false
- noTimezoneConversionForDateType - Don't convert DATE values using the server time zone if 'useTimezone'='true' or 'useLegacyDatetimeCode'='false' Default: true
- noTimezoneConversionForTimeType - Don't convert TIME values using the server time zone if 'useTimezone'='true' Default: false
- nullCatalogMeansCurrent - When DatabaseMetadataMethods ask for a 'catalog' parameter, does the value null mean use the current catalog? (this is not JDBC-compliant, but follows legacy behavior from earlier versions of the driver) Default: true
- nullNamePatternMatchesAll - Should DatabaseMetaData methods that accept *pattern parameters treat null the same as '%' (this is not JDBC-compliant, however older versions of the driver accepted this departure from the specification) Default: true
- overrideSupportsIntegrityEnhancementFacility - Should the driver return "true" for DatabaseMetaData.supportsIntegrityEnhancementFacility() even if the database doesn't support it to workaround applications that require this method to return "true" to signal support of foreign keys, even though the SQL specification states that this facility contains much more than just foreign key support (one such application being OpenOffice)? Default: false
- padCharsWithSpace - If a result set column has the CHAR type and the value does not fill the amount of characters specified in the DDL for the column, should the driver pad the remaining characters with space (for ANSI compliance)? Default: false
- pedantic - Follow the JDBC spec to the letter. Default: false
- pinGlobalTxToPhysicalConnection - When using XAConnections, should the driver ensure that operations on a given XID are always routed to the same physical connection? This allows the XAConnection to support "XA START ... JOIN" after "XA END" has been called Default: false
- populateInsertRowWithDefaultValues - When using ResultSets that are CONCUR_UPDATABLE, should the driver pre-populate the "insert" row with default values from the DDL for the table used in the query so those values are immediately available for ResultSet accessors? This functionality requires a call to the database for metadata each time a result set of this type is created. If disabled (the default), the default values will be populated by the an internal call to refreshRow() which pulls back default values and/or values changed by triggers. Default: false
- processEscapeCodesForPrepStmts - Should the driver process escape codes in queries that are prepared? Default escape processing behavior in non-prepared statements must be defined with the property 'enableEscapeProcessing'. Default: true
- queryTimeoutKillsConnection - If the timeout given in Statement.setQueryTimeout() expires, should the driver forcibly abort the Connection instead of attempting to abort the query? Default: false
- relaxAutoCommit - If the version of MySQL the driver connects to does not support transactions, still allow calls to commit(), rollback() and setAutoCommit() (true/false, defaults to 'false')? Default: false
- retainStatementAfterResultSetClose - Should the driver retain the Statement reference in a ResultSet after ResultSet.close() has been called. This is not JDBC-compliant after JDBC-4.0. Default: false
- rollbackOnPooledClose - Should the driver issue a rollback() when the logical connection in a pool is closed? Default: true
- runningCTS13 - Enables workarounds for bugs in Sun's JDBC compliance testsuite version 1.3 Default: false
- sendFractionalSeconds - Send fractional part from TIMESTAMP seconds. If set to false, the nanoseconds value of TIMESTAMP values will be truncated before sending any data to the server. This option applies only to prepared statements, callable statements or updatable result sets. Default: true
- serverTimezone - Override detection/mapping of time zone. Used when time zone from server doesn't map to Java time zone
- statementInterceptors - A comma-delimited list of classes that implement "com.mysql.jdbc.StatementInterceptor" that should be placed "in between" query execution to influence the results. StatementInterceptors are "chainable", the results returned by the "current" interceptor will be passed on to the next in in the chain, from left-to-right order, as specified in this property.
- strictFloatingPoint - Used only in older versions of compliance test Default: false
- strictUpdates - Should the driver do strict checking (all primary keys selected) of updatable result sets (true, false, defaults to 'true')? Default: true
- tinyInt1isBit - Should the driver treat the datatype TINYINT(1) as the BIT type (because the server silently converts BIT -> TINYINT(1) when creating tables)? Default: true
- transformedBitIsBoolean - If the driver converts TINYINT(1) to a different type, should it use BOOLEAN instead of BIT for future compatibility with MySQL-5.0, as MySQL-5.0 has a BIT type? Default: false
- treatUtilDateAsTimestamp - Should the driver treat java.util.Date as a TIMESTAMP for the purposes of PreparedStatement.setObject()? Default: true
- ultraDevHack - Create PreparedStatements for prepareCall() when required, because UltraDev is broken and issues a prepareCall() for _all_ statements? (true/false, defaults to 'false') Default: false
- useAffectedRows - Don't set the CLIENT_FOUND_ROWS flag when connecting to the server (not JDBC-compliant, will break most applications that rely on "found" rows vs. "affected rows" for DML statements), but does cause "correct" update counts from "INSERT ... ON DUPLICATE KEY UPDATE" statements to be returned by the server. Default: false
- useGmtMillisForDatetimes - Convert between session time zone and GMT before creating Date and Timestamp instances (value of 'false' leads to legacy behavior, 'true' leads to more JDBC-compliant behavior)? This is part of the legacy date-time code, thus the property has an effect only when "useLegacyDatetimeCode=true." Default: false
- useHostsInPrivileges - Add '@hostname' to users in DatabaseMetaData.getColumn/TablePrivileges() (true/false), defaults to 'true'. Default: true
- useInformationSchema - When connected to MySQL-5.0.7 or newer, should the driver use the INFORMATION_SCHEMA to derive information used by DatabaseMetaData? Default: false
- useJDBCCompliantTimezoneShift - Should the driver use JDBC-compliant rules when converting TIME/TIMESTAMP/DATETIME values' time zone information for those JDBC arguments which take a java.util.Calendar argument? This is part of the legacy date-time code, thus the property has an effect only when "useLegacyDatetimeCode=true." Default: false
- useLegacyDatetimeCode - Use code for DATE/TIME/DATETIME/TIMESTAMP handling in result sets and statements that consistently handles time zone conversions from client to server and back again, or use the legacy code for these datatypes that has been in the driver for backwards-compatibility? Setting this property to 'false' voids the effects of "useTimezone," "useJDBCCompliantTimezoneShift," "useGmtMillisForDatetimes," and "useFastDateParsing." Default: true
- useOldAliasMetadataBehavior - Should the driver use the legacy behavior for "AS" clauses on columns and tables, and only return aliases (if any) for ResultSetMetaData.getColumnName() or ResultSetMetaData.getTableName() rather than the original column/table name? In 5.0.x, the default value was true. Default: false
- useOldUTF8Behavior - Use the UTF-8 behavior the driver did when communicating with 4.0 and older servers Default: false
- useOnlyServerErrorMessages - Don't prepend 'standard' SQLState error messages to error messages returned by the server. Default: true
- useSSPSCompatibleTimezoneShift - If migrating from an environment that was using server-side prepared statements, and the configuration property "useJDBCCompliantTimeZoneShift" set to "true", use compatible behavior when not using server-side prepared statements when sending TIMESTAMP values to the MySQL server. Default: false
- useServerPrepStmts - Use server-side prepared statements if the server supports them? Default: false
- useSqlStateCodes - Use SQL Standard state codes instead of 'legacy' X/Open/SQL state codes (true/false), default is 'true' Default: true
- useStreamLengthsInPrepStmts - Honor stream length parameter in PreparedStatement/ResultSet.setXXXStream() method calls (true/false, defaults to 'true')? Default: true
- useTimezone - Convert time/date types between client and server time zones (true/false, defaults to 'false')? This is part of the legacy date-time code, thus the property has an effect only when "useLegacyDatetimeCode=true." Default: false
- useUnbufferedInput - Don't use BufferedInputStream for reading data from the server Default: true
- yearIsDateType - Should the JDBC driver treat the MySQL type "YEAR" as a java.sql.Date, or as a SHORT? Default: true
- zeroDateTimeBehavior - What should happen when the driver encounters DATETIME values that are composed entirely of zeros (used by MySQL to represent invalid dates)? Valid values are "exception", "round" and "convertToNull". Default: exception
â‡’Examples for Connector/J - JDBC Driver for MySQL
â‡’â‡’FAQ for Connector/J - JDBC Driver for MySQL
2016-12-04, 1124👍, 0💬