DP memoized方法用于最长公共子串

时间:2015-06-16 05:36:57

标签: algorithm dynamic-programming

任何人都可以为两个字符串之间的最长公共子字符串提供memoized方法。我知道底层解决方案,但我无法以自上而下的方式思考。 预期时间复杂度-O(n ^ 2)

8 个答案:

答案 0 :(得分:1)

递归的记忆与自上而下的方法一起使用。 下面考虑使用来自Cormen的DP的LCS示例是描述其如何工作的伪代码。

MEMOIZED-LCS-LENGTH(X,Y)
 m<-length[X]
 n<-length[Y]
for(i<-1 to m)
  do for(j<-1 to n)
        c[i,j]<- -1

for(i<-1 to m)
    c[i,0]<-0
for(j<-1 to n)
    c[0,j]<-0
return RECURSIVE-LCS-LENGTH(X,Y,1,1)


RECURSIVE-LCS-LENGTH(X,Y,i,j)
if(c[i,j]!=-1) 
  return c[i,j]
//Above 2 line fetches the result if already present, instead of computing it again.
if(x[i]==y[j]) 
  then c[i,j]<-RECURSIVE-LCS-LENGTH(X,Y,i+1,j+1)+1 
else 
     c1<- RECURSIVE-LCS-LENGTH(X,Y,i+1,j)
     c2<-RECURSIVE-LCS-LENGTH(X,Y,i,j+1)
       if(c1<c2)
         then c[i,j]<-c1
       else c[i,j]<-c2

return c[i,j]

答案 1 :(得分:1)

自上而下的方法

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

string X, Y;             //input strings
int ans, dp[105][105];   // ans : answer

int LCS(int n, int m)    //our function return value of (n,m) sate
{                        // so that we can use the result in (n+1,m+1) state
  if(n == 0 || m == 0) return 0;   //in case of match in (n+1,m+1) state
  if(dp[n][m] != -1) return dp[n][m];

  LCS(n-1,m);          //to visit all n*m states          (try example:  X:ASDF
  LCS(n,m-1);          // we call these states first                     Y:ASDFF)

  if(X[n-1] == Y[m-1])
  {

    dp[n][m] =  LCS(n-1,m-1) + 1;
    ans = max(ans, dp[n][m]);
    return dp[n][m];
  }
    return dp[n][m] = 0;
}

int main()
{
    int t; cin>>t;
    while(t--)
    {
      int n, m; cin>>n>>m;  //length of strings
      cin>>X>>Y;
      memset(dp, -1, sizeof dp);
      ans = 0;
      LCS(n, m);
      cout<<ans<<'\n';
    }
    return 0;
}

答案 2 :(得分:1)

python 中的递归加记忆。请注意,此代码部分被 Hackerearth 和 Geeksforgeeks 接受。对于较大的测试用例,它提供 MLE。

import sys
sys.setrecursionlimit(1000000)
maxlen=0
t=None
def solve(s1, s2, n, m):
   global maxlen, t
   if n<=0 or m<=0:
       return 0
   if t[n][m]!=-1:
       return t[n][m]
   if s1[n-1]==s2[m-1]:
       temp=1+solve(s1, s2, n-1, m-1)
       maxlen=max(maxlen, temp)
       t[n][m]=temp
       return temp
   t[n][m]=0
   return 0
class Solution:
   def longestCommonSubstr(self, S1, S2, n, m):
       global maxlen, t
       maxlen=0
       t=[[-1]*(m+1) for i in range(n+1)]
       for i in range(n+1):
           for j in range(m+1):
               solve(S1, S2, i, j)
       return maxlen
if __name__=='__main__':
   S1=input().strip()
   S2=input().strip()
   n=len(S1)
   m=len(S2)
   ob = Solution()
   print(ob.longestCommonSubstr(S1, S2, n, m))

答案 3 :(得分:0)

以下描述了一种简单的解决方案。 memo[n][m]此处不存储长度 最大子串,但您可以按如下方式将最大子串存储在指针maxi中:

 #include<iostream>
 #include<string>
 using namespace std;
 int lcs(string X,string Y,int n,int m,int *maxi,int memo[][8]) {


if(n==0||m==0) {

return 0;
}
int k=0;
int j=0;

if(memo[n-1][m-1]!=-1) {
return memo[n-1][m-1];
}
if(X[n-1]==Y[m-1]) {

memo[n-1][m-1] =  1+lcs(X,Y,n-1,m-1,maxi,memo);
if(*maxi<memo[n-1][m-1]) 
*maxi=memo[n-1][m-1];

}
else {
memo[n-1][m-1]=0;
}


int l =  lcs(X,Y,n-1,m,maxi,memo);
int i = lcs(X,Y,n,m-1,maxi,memo);

return memo[n-1][m-1];



}

int main() 
{ 
int n,m; 

string X = "abcdxyze"; 
//string X = "abcd";
string Y = "xyzabcde"; 

 n=X.length(); 
 m=Y.length(); 
 int memo[n][8];
 for(int i=0;i<n;i++) {
  for(int j=0;j<m;j++) {
  memo[i][j]=-1;
  }
 }
 int maxi=0;
 int k = lcs(X,Y,n,m,&maxi,memo); 
 cout << maxi;
  return 0; 
 } 

答案 4 :(得分:0)

503 error (Service Unavailable)

答案 5 :(得分:0)

这是一种递归的自上而下的方法:

       public int lcsSubstr(char[] s1, char[] s2, int m, int n, int c) {
            if (m == 0 || n == 0) {
                return c;
            }
            if (s1[m-1] == s2[n-1]) {
                c = lcsSubstr(s1, s2, m-1, n-1, c+1);
            } else {
                c2 = Math.max(lcsSubstr(s1, s2, m, n - 1, 0), lcsSubstr(s1, s2, m-1, n, 0));
            }
            return Math.max(c, c2);
        }

       public int lcsSubstrMemo(char[] s1, char[] s2, int m, int n, int c, int[][] t) {
            if(m == 0 || n == 0) {
                return c;
            }
            if (t[m-1][n-1] != -1) return t[m-1][n-1];
            if(s1[m - 1] == s2[n - 1]) {
                c = lcsSubstr(s1, s2, m - 1, n - 1, c + 1);
            } else {
                c2 = Math.max(lcsSubstr(s1, s2, m, n - 1, 0), lcsSubstr(s1, s2, m - 1, n, 0));
            }
            t[m - 1][n - 1] = Math.max(c, c2);
            return t[m-1][n-1];
        }

答案 6 :(得分:0)

class Solution {
public:
    int t[1005][1005];
    int maxC = 0;
    int recur_memo(vector<int>& nums1, vector<int>& nums2, int m, int n) {
        if(t[m][n] != -1)
            return t[m][n];
    
        if(m == 0 || n == 0)
            return 0;
    
        int max_substring_ending_here = 0;
        //Example : "abcdezf"   "abcdelf"
        //You see that wowww, string1[m-1] = string2[n-1] = 'f' and you happily   
        go for (m-1, n-1)
        //But you see, in future after a gap of 'l' and 'z', you will find 
        "abcde" and "abcde"
        if(nums1[m-1] == nums2[n-1]) {
            max_substring_ending_here = 1 + recur_memo(nums1, nums2, m-1, n-1);
        }
    
        //May be you find better results if you do (m-1, n) and you end up 
        updating maxC with some LAAARGEST COMMON SUBSTRING LENGTH
        int decrease_m = recur_memo(nums1, nums2, m-1, n); //stage (m-1, n)
    
        //OR,
        //May be you find better results if you do (m, n-1) and you end up 
        updating maxC with some LAAARGEST COMMON SUBSTRING LENGTH
        int decrease_n  = recur_memo(nums1, nums2, m, n-1); //stage (m, n-1)
    
        //Like I said, you need to keep on finding the maxC in every call you 
        make throughout your journey.
        maxC = max({maxC, max_substring_ending_here, decrease_m, decrease_n});
    
    
        //BUT BUT BUT, you need to return the best you found at this stage (m, n)
        return t[m][n] = max_substring_ending_here;
    }

    int findLength(vector<int>& nums1, vector<int>& nums2) {
        int m = nums1.size();
        int n = nums2.size();
        memset(t, -1, sizeof(t));
        recur_memo(nums1, nums2, m, n); //resurive+memoization
        return maxC;
    }
};

链接:https://leetcode.com/problems/maximum-length-of-repeated-subarray/discuss/1169215/(1)-Recursive%2BMemo-(2)-Bottom-Up-(C%2B%2B)

答案 7 :(得分:-1)

Memoization指的是将解决方案缓存到子问题,以便以后使用它们。在最长的常见子序列问题中,您尝试匹配两个子序列的子字符串以查看它们是否匹配,在内存中保留已找到的最长子序列。以下是您正在寻找的Java解决方案(LCS的备忘版本):

    ERROR org.springframework.scheduling.quartz.LocalDataSourceJobStore - ClusterManager: Error managing cluster: Failure obtaining db row lock: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM qrtz_LOCKS WHERE SCHED_NAME = 'QuartzJobCheAu' AND LOCK_NAME = ? FOR UPDATE [42102-191]
org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM qrtz_LOCKS WHERE SCHED_NAME = 'QuartzJobCheAu' AND LOCK_NAME = ? FOR UPDATE [42102-191]
    at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:157)
    at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:113)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.doCheckin(JobStoreSupport.java:3258)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3858)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.run(JobStoreSupport.java:3895)
Caused by: org.h2.jdbc.JdbcSQLException: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM qrtz_LOCKS WHERE SCHED_NAME = 'QuartzJobCheAu' AND LOCK_NAME = ? FOR UPDATE [42102-191]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.command.Parser.readTableOrView(Parser.java:5349)
    at org.h2.command.Parser.readTableFilter(Parser.java:1245)
    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1884)
    at org.h2.command.Parser.parseSelectSimple(Parser.java:2032)
    at org.h2.command.Parser.parseSelectSub(Parser.java:1878)
    at org.h2.command.Parser.parseSelectUnion(Parser.java:1699)
    at org.h2.command.Parser.parseSelect(Parser.java:1687)
    at org.h2.command.Parser.parsePrepared(Parser.java:443)
    at org.h2.command.Parser.parse(Parser.java:315)
    at org.h2.command.Parser.parse(Parser.java:287)
    at org.h2.command.Parser.prepareCommand(Parser.java:252)
    at org.h2.engine.Session.prepareLocal(Session.java:560)
    at org.h2.engine.Session.prepareCommand(Session.java:501)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1188)
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:276)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
    at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108)
    at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81)
    at com.sun.proxy.$Proxy59.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
    at com.sun.proxy.$Proxy60.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:240)
    at com.sun.proxy.$Proxy60.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:73)
    at com.sun.proxy.$Proxy93.prepareStatement(Unknown Source)
    at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:88)
    ... 4 common frames omitted
ERROR org.springframework.scheduling.quartz.LocalDataSourceJobStore - ClusterManager: Error managing cluster: Failure obtaining db row lock: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM qrtz_LOCKS WHERE SCHED_NAME = 'QuartzJobCheAu' AND LOCK_NAME = ? FOR UPDATE [42102-191]
org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM qrtz_LOCKS WHERE SCHED_NAME = 'QuartzJobCheAu' AND LOCK_NAME = ? FOR UPDATE [42102-191]
    at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:157)
    at org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:113)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.doCheckin(JobStoreSupport.java:3258)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.manage(JobStoreSupport.java:3858)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$ClusterManager.run(JobStoreSupport.java:3895)
Caused by: org.h2.jdbc.JdbcSQLException: Table "QRTZ_LOCKS" not found; SQL statement:
SELECT * FROM qrtz_LOCKS WHERE SCHED_NAME = 'QuartzJobCheAu' AND LOCK_NAME = ? FOR UPDATE [42102-191]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.command.Parser.readTableOrView(Parser.java:5349)
    at org.h2.command.Parser.readTableFilter(Parser.java:1245)
    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1884)
    at org.h2.command.Parser.parseSelectSimple(Parser.java:2032)
    at org.h2.command.Parser.parseSelectSub(Parser.java:1878)
    at org.h2.command.Parser.parseSelectUnion(Parser.java:1699)
    at org.h2.command.Parser.parseSelect(Parser.java:1687)
    at org.h2.command.Parser.parsePrepared(Parser.java:443)
    at org.h2.command.Parser.parse(Parser.java:315)
    at org.h2.command.Parser.parse(Parser.java:287)
    at org.h2.command.Parser.prepareCommand(Parser.java:252)
    at org.h2.engine.Session.prepareLocal(Session.java:560)
    at org.h2.engine.Session.prepareCommand(Session.java:501)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1188)
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:276)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
    at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108)
    at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81)
    at com.sun.proxy.$Proxy59.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
    at com.sun.proxy.$Proxy60.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:240)
    at com.sun.proxy.$Proxy60.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:73)
    at com.sun.proxy.$Proxy93.prepareStatement(Unknown Source)
    at org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:88)
    ... 4 common frames omitted
ERROR org.springframework.scheduling.quartz.LocalDataSourceJobStore - MisfireHandler: Error handling misfires: Database error recovering from misfires.
org.quartz.JobPersistenceException: Database error recovering from misfires.
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3197)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.manage(JobStoreSupport.java:3935)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport$MisfireHandler.run(JobStoreSupport.java:3956)
Caused by: org.h2.jdbc.JdbcSQLException: Table "QRTZ_TRIGGERS" not found; SQL statement:
SELECT COUNT(TRIGGER_NAME) FROM qrtz_TRIGGERS WHERE SCHED_NAME = 'QuartzJobCheAu' AND NOT (MISFIRE_INSTR = -1) AND NEXT_FIRE_TIME < ? AND TRIGGER_STATE = ? [42102-191]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
    at org.h2.message.DbException.get(DbException.java:179)
    at org.h2.message.DbException.get(DbException.java:155)
    at org.h2.command.Parser.readTableOrView(Parser.java:5349)
    at org.h2.command.Parser.readTableFilter(Parser.java:1245)
    at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1884)
    at org.h2.command.Parser.parseSelectSimple(Parser.java:2032)
    at org.h2.command.Parser.parseSelectSub(Parser.java:1878)
    at org.h2.command.Parser.parseSelectUnion(Parser.java:1699)
    at org.h2.command.Parser.parseSelect(Parser.java:1687)
    at org.h2.command.Parser.parsePrepared(Parser.java:443)
    at org.h2.command.Parser.parse(Parser.java:315)
    at org.h2.command.Parser.parse(Parser.java:287)
    at org.h2.command.Parser.prepareCommand(Parser.java:252)
    at org.h2.engine.Session.prepareLocal(Session.java:560)
    at org.h2.engine.Session.prepareCommand(Session.java:501)
    at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1188)
    at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
    at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:276)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:126)
    at org.apache.tomcat.jdbc.pool.JdbcInterceptor.invoke(JdbcInterceptor.java:108)
    at org.apache.tomcat.jdbc.pool.DisposableConnectionFacade.invoke(DisposableConnectionFacade.java:81)
    at com.sun.proxy.$Proxy59.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
    at com.sun.proxy.$Proxy60.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:240)
    at com.sun.proxy.$Proxy60.prepareStatement(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor182.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
    at org.quartz.impl.jdbcjobstore.AttributeRestoringConnectionInvocationHandler.invoke(AttributeRestoringConnectionInvocationHandler.java:73)
    at com.sun.proxy.$Proxy93.prepareStatement(Unknown Source)
    at org.quartz.impl.jdbcjobstore.StdJDBCDelegate.countMisfiredTriggersInState(StdJDBCDelegate.java:390)
    at org.quartz.impl.jdbcjobstore.JobStoreSupport.doRecoverMisfires(JobStoreSupport.java:3176)
    ... 2 common frames omitted