Configuring Quartz Datasources
If you're using the JDBC JobStore, you'll need to define a datasource for its use. If you're using the JobStoreCMT, you'll actually need to define two datasources. Datasources can be configured in three ways:
- The pool properties are specified in the quartz.properties file so that Quartz can create the Datasource itself.
- The JNDI location of an application server managed Datasource can be specified so that Quartz can use it.
- A custom-defined org.quartz.utils.ConnectionProvider implementation can be used.
Each datasource that you define must be given a name, and the properties you define for each must contain that name. The dataSource's NAME can be anything you want; it has no meaning and simply identifies the datasource when it is assigned to the JDBC JobStore.
When configuring a datasource using quartz.properties to define all the pool properties, the properties in Table A.6 are available for use.
Name |
Required |
Type |
Default Value |
---|---|---|---|
org.quartz.dataSource.NAME.driver |
Yes |
String |
Null |
org.quartz.dataSource.NAME.URL |
Yes |
String |
null |
org.quartz.dataSource.NAME.user |
No |
String |
"" |
org.quartz.dataSource.NAME.password |
No |
String |
"" |
org.quartz.dataSource.NAME.maxConnections |
No |
Integer |
10 |
org.quartz.dataSource.NAME.validationQuery |
No |
String |
null |
org.quartz.jobStore.clusterCheckinInterval |
No |
Long |
15000 |
org.quartz.dataSource.NAME.driver
This must be the Java class name of the JDBC driver for your database.
org.quartz.dataSource.NAME.URL
This is the connection URL (host, port, and so on) for connection to your database.
org.quartz.dataSource.NAME.user
This is the username to use when connecting to your database.
org.quartz.dataSource.NAME.password
This is the password to use when connecting to your database.
org.quartz.dataSource.NAME.maxConnections
This is the maximum number of connections that the DataSource can create in its pool of connections.
org.quartz.dataSource.NAME.validationQuery
This is an optional SQL query string that the DataSource can use to detect and replace failed/corrupt connections. For example, an Oracle user might choose select table_name from user_tables, which is a query that should never fail unless the connection is actually bad.
When you're using the Datasource defined in an application server, the properties in Table A.7 are available.
Name |
Required |
Type |
Default Value |
---|---|---|---|
org.quartz.dataSource.NAME.jndiURL |
Yes |
String |
null |
org.quartz.dataSource.NAME.java.naming.factory.initial |
No |
String |
null |
org.quartz.dataSource.NAME.java.naming.provider.url |
No |
String |
null |
org.quartz.dataSource.NAME.java.naming.security.principal |
No |
String |
null |
org.quartz.dataSource.NAME.java.naming.security.credentials |
No |
String |
null |
org.quartz.dataSource.NAME.jndiURL
This is the JNDI URL for a DataSource that is managed by your application server.
org.quartz.dataSource.NAME.java.naming.factory.initial
This is the (optional) class name of the JNDI InitialContextFactory that you want to use.
org.quartz.dataSource.NAME.java.naming.provider.url
This is the (optional) URL for connecting to the JNDI context.
org.quartz.dataSource.NAME.java.naming.security.principal
This is the (optional) user principal for connecting to the JNDI context.
org.quartz.dataSource.NAME.java.naming.security.credentials
These are the (optional) user credentials for connecting to the JNDI context.