Reputation: 223
Someone could point me to some resources on what the list of parameters appended after this JDBC URL actually means?
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>
Upvotes: 1
Views: 14486
Reputation: 4553
There is a documentation page for that, search internet for "mysql connector-j-reference-configuration-properties".
Upvotes: 0
Reputation: 978
connectTimeout=2000 means to wait up to 2 seconds to establish a connection. Defaults to not timeout.
socketTimeout=2000 means to wait up to 2 seconds for network socket operations.
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.
paranoid=true takes measures to prevent exposure sensitive information in error messages and clear data structures holding sensitive data when possible.
autoReconnect=true tells the driver try to re-establish stale and/or dead connections. 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. Alternatively, as a last option, investigate setting the MySQL server variable "wait_timeout" to a high value, rather than the default of 8 hours.
The following apply only when autoReconnect mode is on.
failOverReadOnly=false means don't make the connection to be read-only when failing over.
maxReconnects=2 Maximum number of reconnects to attempt, default is '3'.
initialTimeout=2 The initial time to wait between re-connect attempts. Default 2
See http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html
Upvotes: 4