javaapache-commons-dbcp

Which units do Apache DBCP defaultQueryTimeout expects?


The Apache Commons DBCP's documentation states, that

defaultQueryTimeout
If non-null, the value of this Integer property determines the query timeout that will be used for Statements created from connections managed by the pool. null means that the driver default will be used.

But they forgot to mention which [time] units they expect. The same forgetfulness is in the Javadoc.

I assume that timeout is in seconds, because validationQueryTimeout expects timeout in seconds, but it's only an assumption.

So what units apply to the defaultQueryTimeout? Also seconds?


Solution

  • The two values are effectively in seconds.

    The wanted informations are available in the Javadoc of the class BasicDataSource

    getDefaultQueryTimeout 
    [***]
    Returns:
    The default query timeout in seconds.
    
    getValidationQueryTimeout
    [***]
    Returns:
    the timeout in seconds before connection validation queries fail.
    

    You could also read the source code of this class for more informations