简体   繁体   English

Tomcat 上下文中的 MySQL JDBC 连接 URL 参数

[英]MySQL JDBC Connection URL Params in Tomcat Context

Someone could point me to some resources on what the list of parameters appended after this JDBC URL actually means?有人可以向我指出一些关于附加在此 JDBC URL 后面的参数列表实际上意味着什么的资源?

Thanks!谢谢!

<Context>
<Resource 
name="jdbc/DB" auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
username="user" password="password" 
maxActive="20" 
maxIdle="5" 
url="jdbc:mysql://192.168.0.10:3306,192.168.0.11:3306/testDB?
    autoReconnect=true&amp
    failOverReadOnly=false&amp
    maxReconnects=2&amp
    initialTimeout=2&amp
    connectTimeout=2000&amp 
    socketTimeout=2000&amp
    useLocalSessionState=true&amp
    paranoid=true&amp"
/>
</Context>

Connection/Authentication连接/认证

connectTimeout =2000 means to wait up to 2 seconds to establish a connection. connectTimeout =2000 表示最多等待 2 秒才能建立连接。 Defaults to not timeout.默认不超时。

socketTimeout =2000 means to wait up to 2 seconds for network socket operations. socketTimeout =2000 表示最多等待 2 秒网络套接字操作。

Performance Extensions性能扩展

useLocalSessionState =true tells the driver to refer to the internal values of autocommit and transaction isolation that are set by Connection.setAutoCommit() and Connection.setTransactionIsolation() and transaction state as maintained by the protocol, rather than querying the database or blindly sending commands to the database for commit() or rollback() method calls. useLocalSessionState =true 告诉驱动程序参考 Connection.setAutoCommit() 和 Connection.setTransactionIsolation() 设置的自动提交和事务隔离的内部值以及协议维护的事务状态,而不是查询数据库或盲目发送命令到数据库以进行 commit() 或 rollback() 方法调用。

paranoid =true takes measures to prevent exposure sensitive information in error messages and clear data structures holding sensitive data when possible. paranoid =true 采取措施防止在错误消息中暴露敏感信息,并在可能的情况下清除保存敏感数据的数据结构。

High Availability and Clustering.高可用性和集群。

autoReconnect =true tells the driver try to re-establish stale and/or dead connections. autoReconnect =true 告诉驱动程序尝试重新建立陈旧和/或死连接。 The driver will throw an exception for any query issued on a stale or dead connection, which belong to the current transaction, but will attempt reconnect before the next query issued on the connection in a new transaction.驱动程序将对在陈旧或死连接上发出的任何查询抛出异常,这些查询属于当前事务,但会在新事务中的连接上发出下一个查询之前尝试重新连接。 Turning this on is not recommended , because it has side effects related to session state and data consistency when applications don't handle SQLExceptions properly, and is only designed to be used when you are unable to configure your application to handle SQLExceptions resulting from dead and stale connections properly.不建议启用此功能,因为当应用程序不能正确处理 SQLExceptions 时,它会产生与会话状态和数据一致性相关的副作用,并且仅在您无法配置应用程序以处理由死和陈旧的连接正确。 Alternatively, as a last option, investigate setting the MySQL server variable "wait_timeout" to a high value, rather than the default of 8 hours.或者,作为最后一个选项,调查将 MySQL 服务器变量“wait_timeout”设置为高值,而不是默认值 8 小时。

The following apply only when autoReconnect mode is on.以下仅在自动重新连接模式开启时适用。

failOverReadOnly =false means don't make the connection to be read-only when failing over. failOverReadOnly =false 表示故障转移时不要将连接设为只读。

maxReconnects =2 Maximum number of reconnects to attempt, default is '3'. maxReconnects =2 尝试重新连接的最大次数,默认为“3”。

initialTimeout =2 The initial time to wait between re-connect attempts. initialTimeout =2 重新连接尝试之间等待的初始时间。 Default 2默认 2

See http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html请参阅http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html

有一个文档页面,在互联网上搜索“mysql connector-j-reference-configuration-properties”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Tomcat上下文资源定义JDBC连接:隐藏连接凭证 - Using Tomcat Context Resource to define JDBC connection: Hiding connection credentials 带有JDBC的tomcat 6.0抛出ClassNotFoundException com.mysql.jdbc.Connection - tomcat 6.0 with JDBC throws ClassNotFoundException com.mysql.jdbc.Connection 用于 treeAnno 的 tomcat 9 context.xml 中 JDBC URL 的问题 - Problems with JDBC URL in tomcat 9 context.xml for treeAnno JAVA:通过URL的JDBC连接Aurora(mysql)aws - JAVA: JDBC Connection by URL Aurora(mysql) aws Tomcat和JDBC连接池 - Tomcat and JDBC connection pooling Tomcat Server in Eclipse: Could not find or load main class db.connection.url=jdbc:mysql:..localhost:port.schema - Tomcat Server in Eclipse: Could not find or load main class db.connection.url=jdbc:mysql:..localhost:port.schema 在Web应用程序(jsp,Tomcat和MySQL)中使用jdbc连接 - Use jdbc connection in a web application (jsp, Tomcat and MySQL) SQLException w / Tomcat 7.0 JDBC连接池和MySql - SQLException w/ Tomcat 7.0 JDBC connection pool and MySql 如何在context.xml中调整MySQL连接池参数 - How to tune MySQL connection pool params in context.xml 带有mysql的Tomcat:“无法为连接URL&#39;null&#39;创建类”的JDBC驱动程序” - Tomcat with mysql : “ Cannot create JDBC driver of class '' for connect URL 'null' ”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM