|
|
Posted on 2022-2-11 13:59:18
|
|
|

Optimized the performance of Java JDBC's rewriteBatchedStatements, allowPublicKeyRetrieval, allowMultiQueries, and sslMode configurations.
jdbc All Configuration Properties Documentation:The hyperlink login is visible.
Review:
allowPublicKeyRetrieval
When using MySQL 8.0, after restarting the app, you are prompted com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
The easiest workaround is to add it after the connectionallowPublicKeyRetrieval=true
If the user uses sha256_password authentication, the password must be protected in transit using the TLS protocol, but if the RSA public key is not available, the public key provided by the server can be used; The RSA public key of the server can be specified in the connection via ServerRSAPublicKeyFile, or the AllowPublicKeyRetrieval=True parameter to allow the client to obtain the public key from the server; However, it should be noted that AllowPublicKeyRetrieval=True may cause malicious agents to obtain plaintext passwords through man-in-the-middle attacks (MITM), so it is turned off by default and must be explicitly enabled.
rewriteBatchedStatements
In order to achieve high-performance batch insertion by adding the rewriteBatchedStatements parameter to the URL of the JDBC connection in MySQL and ensuring that the driver version 5.1.13 or later is guaranteed. By default, the MySQL JDBC driver ignores the executeBatch() statement, splits a set of SQL statements that we expect to execute in batches, and sends them to the MySQL database one by one. Only by setting the rewriteBatchedStatements parameter to true will the driver execute the SQL in batches This option is also valid for INSERT/UPDATE/DELETE
By default, the MySQL Jdbc driver ignores the executeBatch() statement, breaks up a set of SQL statements that we expect to execute in batches, and sends them to the MySQL database one by one, which directly causes low performance.
Only by setting the rewriteBatchedStatements parameter to true, the driver will help you execute SQL in bulk (jdbc:mysql://ip:port/db?)rewriteBatchedStatements=true)
allowMultiQueries
Permission to use'; ' Separates multiple queries (true/false) in one statement. The default value is "false", which does not affect the addBatch() and executeBatch() methods, which depend on rewriteBatchStatements.
When MySQL connects to a database, add the statement:"allowMultiQueries=trueThe role of ":
1. You can carry a semicolon after the SQL statement to achieve multi-statement execution. 2. Batch processing can be performed and multiple SQL statements can be issued at the same time.
sslMode
By default, network connections are SSL encrypted; This property allows you to turn off the secure connection, or select a different level of security. The following values are allowed: "DISABLED" - an unencrypted connection is established; "PREFERRED" - (default) If the server enables encrypted connections, an encrypted connection is established, otherwise it falls back to an unencrypted connection; "REQUIRED" - Establish a secure connection if the server has enabled it, otherwise it fails; "VERIFY_CA" - Similar to "REQUIRED", but additionally validates the server TLS certificate against the configured certificate authority (CA) certificate; "VERIFY_IDENTITY" - like "VERIFY_CA",
This attribute replaces the deprecated old attributes "useSSL", "requireSSL", and "verifyServerCertificate", which are still accepted but converted to the value of "sslMode" if "sslMode" is not explicitly set: "useSSL=false" is converted to "sslMode=disabled"; {"useSSL=true", "requireSSL=false", "verifyServerCertificate=false"} is translated as "sslMode=PREFERRED"; {"useSSL=true", "requireSSL=true", "verifyServerCertificate=false"} is translated as "sslMode=REQUIRED"; {"useSSL=true" AND "verifyServerCertificate=true"} is translated as "The default setting for "sslMode" is "PREFERRED", which is equivalent to the traditional "useSSL=true", "requireSSL=false" and "verifyServerCertificate=false" settings, which is the same as the Connector/ The default settings for J 8.0.12 and earlier versions are different in some cases. Applications that continue to use the old attributes and rely on their old defaults should be reviewed. The default setting for "sslMode" is "PREFERRED", which is equivalent to the traditional settings of "useSSL=true", "requireSSL=false" and "verifyServerCertificate=false", which is different from the default setting for Connector/ J 8.0.12 and earlier in some cases. Applications that continue to use the old attributes and rely on their old defaults should be reviewed. In some cases it is 12 or earlier. Applications that continue to use the old attributes and rely on their old defaults should be reviewed. In some cases it is 12 or earlier. Applications that continue to use the old attributes and rely on their old defaults should be reviewed.
If "sslMode" is explicitly set, the old property is ignored. If "sslMode" or "useSSL" is not explicitly set, the default setting "sslMode=PREFERRED" is applied.
JDBC settings to turn off secure connections:sslmode=disabled
|
Previous:How to rename files in batches in LinuxNext:How to restrict Taiwanese users from registering, post information at will, and ask for advice on how to write.
|