Quartz与MSSQLServer配合问题记录

在使用Quartz的数据库存储方式时, 当数据库是MSSQLServer时会出现如下异常

Caused by: java.sql.SQLException: 第 1 行: 只有 DECLARE CURSOR 才允许使用 FOR UPDATE 子句。
	at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
	at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
	at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
	at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
	at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:418)
	at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:693)
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
	at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:89)
	... 63 more

 

解决方法,在quartz.properties文件中添加如下配置

org.quartz.jobStore.selectWithLockSQL=SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ? 

 

附上异常的详细信息, 这边采用的是spring结合Quartz的方式

你可能感兴趣的:(java,spring,.net,quartz,jdbc)