aHaH
aHaH

Reputation: 223

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?

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>

Upvotes: 1

Views: 14486

Answers (2)

Rostislav Matl
Rostislav Matl

Reputation: 4553

There is a documentation page for that, search internet for "mysql connector-j-reference-configuration-properties".

Upvotes: 0

Trevor Allred
Trevor Allred

Reputation: 978

Connection/Authentication

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.

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.

paranoid=true takes measures to prevent exposure sensitive information in error messages and clear data structures holding sensitive data when possible.

High Availability and Clustering.

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

Related Questions