[英]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&
failOverReadOnly=false&
maxReconnects=2&
initialTimeout=2&
connectTimeout=2000&
socketTimeout=2000&
useLocalSessionState=true&
paranoid=true&"
/>
</Context>
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 秒网络套接字操作。
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 采取措施防止在错误消息中暴露敏感信息,并在可能的情况下清除保存敏感数据的数据结构。
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.