配置属性定义连接器/ J将如何连接到MySQL服务器。除非另有说明,否则可以为数据源
对象或用于连接
对象。
配置属性可以通过以下方式设置:
使用
设置* ()
方法的MySQL实现java.sql.DataSource
(这是使用的实现时的首选方法java.sql.DataSource
):com.mysql.cj.jdbc.MysqlDataSource
com.mysql.cj.jdbc.MysqlConnectionPoolDataSource
的键-值对
java.util.Properties
实例传递给DriverManager.getConnection ()
或Driver.connect ()
作为给定URL中的JDBC URL参数
java.sql.DriverManager.getConnection ()
,java.sql.Driver.connect ()
的MySQL实现javax.sql.DataSource
setURL ()
方法。如果您在URL中指定配置属性而没有为其提供值,则什么也不会设置;例如,添加useServerPrepStmts
单独到URL不使Connector/J使用服务器端准备语句;你需要添加useServerPrepStmts = true
.请注意如果用于配置JDBC URL的机制是基于XML的,则使用XML字符文字
,
分隔配置参数,因为“&”是XML的保留字符。
属性是按类别列出的,先在下表中列出,然后在下面的子部分中列出。点击表中属性名看到部分的完整描述。
表6.2连接属性
的名字 | 默认值 | 从版本 |
---|---|---|
connectionAttributes |
- | 5.1.25 |
connectionLifecycleInterceptors |
- | 5.1.4 |
useConfigs |
- | 3.1.5 |
authenticationPlugins |
- | 5.1.19 |
clientInfoProvider |
com.mysql.cj.jdbc.CommentClientInfoProvider | 5.1.0 |
createDatabaseIfNotExist |
假 | 3.1.9 |
databaseTerm |
目录 | 8.0.17 |
defaultAuthenticationPlugin |
mysql_native_password | 5.1.19 |
detectCustomCollations |
假 | 5.1.29 |
disabledAuthenticationPlugins |
- | 5.1.19 |
disconnectOnExpiredPasswords |
真正的 | 5.1.23 |
interactiveClient |
假 | 3.1.0 |
ldapServerHostname |
- | 8.0.23 |
passwordCharacterEncoding |
- | 5.1.7 |
propertiesTransform |
- | 3.1.4 |
rollbackOnPooledClose |
真正的 | 3.0.15 |
useAffectedRows |
假 | 5.1.7 |
表6.3会话属性
的名字 | 默认值 | 从版本 |
---|---|---|
sessionVariables |
- | 3.1.8中 |
characterEncoding |
- | 1.1克 |
characterSetResults |
- | 3.0.13 |
connectionCollation |
- | 3.0.13 |
表6.4网络属性
的名字 | 默认值 | 从版本 |
---|---|---|
socksProxyHost |
- | 5.1.34 |
socksProxyPort |
1080 | 5.1.34 |
socketFactory |
com.mysql.cj.protocol.StandardSocketFactory | 3.0.3 |
connectTimeout |
0 | 3.0.1 |
socketTimeout |
0 | 3.0.1 |
dnsSrv |
假 | 8.0.19 |
localSocketAddress |
- | 5.0.5 |
maxAllowedPacket |
65535 | 5.1.8 |
tcpKeepAlive |
真正的 | 5.0.7 |
tcpNoDelay |
真正的 | 5.0.7 |
tcpRcvBuf |
0 | 5.0.7 |
tcpSndBuf |
0 | 5.0.7 |
tcpTrafficClass |
0 | 5.0.7 |
useCompression |
假 | 3.0.17 |
useUnbufferedInput |
真正的 | 此处 |
表6.5安全属性
的名字 | 默认值 | 从版本 |
---|---|---|
偏执 |
假 | 3.0.1 |
serverRSAPublicKeyFile |
- | 5.1.31 |
allowPublicKeyRetrieval |
假 | 5.1.31 |
sslMode |
首选 | 8.0.13 |
trustCertificateKeyStoreUrl |
- | 5.1.0 |
trustCertificateKeyStoreType |
JKS | 5.1.0 |
trustCertificateKeyStorePassword |
- | 5.1.0 |
fallbackToSystemTrustStore |
真正的 | 8.0.22 |
clientCertificateKeyStoreUrl |
- | 5.1.0 |
clientCertificateKeyStoreType |
JKS | 5.1.0 |
clientCertificateKeyStorePassword |
- | 5.1.0 |
fallbackToSystemKeyStore |
真正的 | 8.0.22 |
enabledSSLCipherSuites |
- | 5.1.35 |
enabledTLSProtocols |
- | 8.0.8 |
allowLoadLocalInfile |
假 | 3.0.3 |
allowLoadLocalInfileInPath |
- | 8.0.22 |
allowMultiQueries |
假 | 3.1.1 |
allowUrlInLocalInfile |
假 | 3.1.4 |
requireSSL |
假 | 3.1.0 |
useSSL |
真正的 | 3.0.2 |
verifyServerCertificate |
假 | 5.1.6 |
表6.6语句属性
的名字 | 默认值 | 从版本 |
---|---|---|
cacheDefaultTimeZone |
真正的 | 8.0.20 |
continueBatchOnError |
真正的 | 3.0.3 |
dontTrackOpenResources |
假 | 3.1.7 |
queryInterceptors |
- | 8.0.7 |
queryTimeoutKillsConnection |
假 | 5.1.9 |
表6.7预处理语句属性
的名字 | 默认值 | 从版本 |
---|---|---|
allowNanAndInf |
假 | 3.1.5 |
autoClosePStmtStreams |
假 | 3.1.12 |
compensateOnDuplicateKeyUpdateCounts |
假 | 5.1.7 |
emulateUnsupportedPstmts |
真正的 | 3.1.7 |
generateSimpleParameterMetadata |
假 | 5.0.5 |
processEscapeCodesForPrepStmts |
真正的 | 3.1.12 |
useServerPrepStmts |
假 | 3.1.0 |
useStreamLengthsInPrepStmts |
真正的 | 3.0.2 |
表6.8结果集属性
的名字 | 默认值 | 从版本 |
---|---|---|
clobberStreamingResults |
假 | 3.0.9 |
emptyStringsConvertToZero |
真正的 | 3.1.8中 |
holdResultsOpenOverStatementClose |
假 | 3.1.7 |
jdbcCompliantTruncation |
真正的 | 3.1.2 |
maxRows |
-1 | 所有版本 |
netTimeoutForStreamingResults |
600 | 5.1.0 |
padCharsWithSpace |
假 | 5.0.6 |
populateInsertRowWithDefaultValues |
假 | 5.0.5 |
scrollTolerantForwardOnly |
假 | 8.0.24 |
strictUpdates |
真正的 | 3.0.4 |
tinyInt1isBit |
真正的 | 3.0.16 |
transformedBitIsBoolean |
假 | 3.1.9 |
表6.9元数据属性
的名字 | 默认值 | 从版本 |
---|---|---|
getProceduresReturnsFunctions |
真正的 | 5.1.26 |
noAccessToProcedureBodies |
假 | 5.0.3 |
nullDatabaseMeansCurrent |
假 | 3.1.8中 |
useHostsInPrivileges |
真正的 | 3.0.2 |
useInformationSchema |
假 | 5.0.0 |
表6.10 BLOB/CLOB处理属性
的名字 | 默认值 | 从版本 |
---|---|---|
autoDeserialize |
假 | 3.1.5 |
blobSendChunkSize |
1048576 | 3.1.9 |
blobsAreStrings |
假 | 5.0.8 |
clobCharacterEncoding |
- | 5.0.0 |
emulateLocators |
假 | 3.1.0 |
functionsNeverReturnBlobs |
假 | 5.0.8 |
locatorFetchBufferSize |
1048576 | 3.2.1之上 |
表6.11 Datetime类型处理属性
的名字 | 默认值 | 从版本 |
---|---|---|
connectionTimeZone |
- | 3.0.2 |
forceConnectionTimeZoneToSession |
假 | 8.0.23 |
noDatetimeStringSync |
假 | 3.1.7 |
preserveInstants |
真正的 | 8.0.23 |
sendFractionalSeconds |
真正的 | 5.1.37 |
sendFractionalSecondsForTime |
真正的 | 8.0.23 |
treatUtilDateAsTimestamp |
真正的 | 5.0.5 |
yearIsDateType |
真正的 | 3.1.9 |
zeroDateTimeBehavior |
异常 | 3.1.4 |
表6.12高可用性和集群属性
表6.13性能扩展属性
的名字 | 默认值 | 从版本 |
---|---|---|
callableStmtCacheSize |
One hundred. | 3.1.2 |
metadataCacheSize |
50 | 3.1.1 |
useLocalSessionState |
假 | 3.1.7 |
useLocalTransactionState |
假 | 5.1.7 |
prepStmtCacheSize |
25 | 3.0.10 |
prepStmtCacheSqlLimit |
256 | 3.0.10 |
parseInfoCacheFactory |
com.mysql.cj.PerConnectionLRUFactory | 5.1.1 |
serverConfigCacheFactory |
com.mysql.cj.util.PerVmServerConfigCacheFactory | 5.1.1 |
alwaysSendSetIsolation |
真正的 | 3.1.7 |
maintainTimeStats |
真正的 | 3.1.9 |
useCursorFetch |
假 | 5.0.0 |
cacheCallableStmts |
假 | 3.1.2 |
cachePrepStmts |
假 | 3.0.10 |
cacheResultSetMetadata |
假 | 3.1.1 |
cacheServerConfiguration |
假 | 3.1.5 |
defaultFetchSize |
0 | 3.1.9 |
dontCheckOnDuplicateKeyUpdateInSQL |
假 | 5.1.32 |
elideSetAutoCommits |
假 | 3.1.3 |
enableEscapeProcessing |
真正的 | 6.0.1中 |
enableQueryTimeouts |
真正的 | 5.0.6 |
largeRowSizeThreshold |
2048 | 5.1.1 |
readOnlyPropagatesToServer |
真正的 | 5.1.35 |
rewriteBatchedStatements |
假 | 3.1.13 |
useReadAheadInput |
真正的 | 3.1.5 |
表6.14调试/分析属性
的名字 | 默认值 | 从版本 |
---|---|---|
日志记录器 |
com.mysql.cj.log.StandardLogger | 3.1.1 |
profilerEventHandler |
com.mysql.cj.log.LoggingProfilerEventHandler | 5.1.6 |
useNanosForElapsedTime |
假 | 5.0.7 |
maxQuerySizeToLog |
2048 | 3.1.3 |
profileSQL |
假 | 3.1.0 |
logSlowQueries |
假 | 3.1.2 |
slowQueryThresholdMillis |
2000 | 3.1.2 |
slowQueryThresholdNanos |
0 | 5.0.7 |
autoSlowLog |
真正的 | 5.1.4 |
explainSlowQueries |
假 | 3.1.2 |
gatherPerfMetrics |
假 | 3.1.2 |
reportMetricsIntervalMillis |
30000 | 3.1.2 |
logXaCommands |
假 | 5.0.5 |
traceProtocol |
假 | 3.1.2 |
enablePacketDebug |
假 | 3.1.3 |
packetDebugBufferSize |
20. | 3.1.3 |
useUsageAdvisor |
假 | 3.1.1 |
resultSetSizeThreshold |
One hundred. | 5.0.5 |
autoGenerateTestcaseScript |
假 | 3.1.9 |
表6.15异常/警告属性
的名字 | 默认值 | 从版本 |
---|---|---|
dumpQueriesOnException |
假 | 3.1.3 |
exceptionInterceptors |
- | 5.1.8 |
ignoreNonTxTables |
假 | 3.0.9 |
includeInnodbStatusInDeadlockExceptions |
假 | 5.0.7 |
includeThreadDumpInDeadlockExceptions |
假 | 5.1.15 |
includeThreadNamesAsStatementComment |
假 | 5.1.15 |
useOnlyServerErrorMessages |
真正的 | 3.0.15 |
表6.16曲调与其他产品的集成特性
的名字 | 默认值 | 从版本 |
---|---|---|
overrideSupportsIntegrityEnhancementFacility |
假 | 3.1.12 |
ultraDevHack |
假 | 2.0.3 |
表6.17 JDBC合规属性
的名字 | 默认值 | 从版本 |
---|---|---|
useColumnNamesInFindColumn |
假 | 5.1.7 |
学究式的 |
假 | 3.0.0 |
useOldAliasMetadataBehavior |
假 | 5.0.4 |
表6.18 X协议和X DevAPI属性
的名字 | 默认值 | 从版本 |
---|---|---|
xdevapi.auth |
平原 | 8.0.8 |
xdevapi.compression |
首选 | 8.0.20 |
xdevapi.compression-algorithms |
zstd_stream、lz4_message deflate_stream | 8.0.22 |
xdevapi.compression-extensions |
- | 8.0.22 |
xdevapi.connect-timeout |
10000 | 8.0.13 |
xdevapi.connection-attributes |
- | 8.0.16 |
xdevapi.dns-srv |
假 | 8.0.19 |
xdevapi.fallback-to-system-keystore |
真正的 | 8.0.22 |
xdevapi.fallback-to-system-truststore |
真正的 | 8.0.22 |
xdevapi.ssl-keystore |
- | 8.0.22 |
xdevapi.ssl-keystore-password |
- | 8.0.22 |
xdevapi.ssl-keystore-type |
JKS | 8.0.22 |
xdevapi.ssl-mode |
要求 | 8.0.7 |
xdevapi.ssl-truststore |
- | 6.0.6 |
xdevapi.ssl-truststore-password |
- | 6.0.6 |
xdevapi.ssl-truststore-type |
JKS | 6.0.6 |
xdevapi.tls-ciphersuites |
- | 8.0.19 |
xdevapi.tls-versions |
- | 8.0.19 |