/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package com.opensymphony.workflow.spi.jdbc;

import com.opensymphony.workflow.StoreException;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.Map;


/**
 * @author Christopher Farnham
 * Created on Feb 27, 2004
 */
public class MySQLWorkflowStore extends JDBCWorkflowStore {
    //~ Instance fields ////////////////////////////////////////////////////////

    private String entrySequenceIncrement = null;
    private String entrySequenceRetrieve = null;
    private String stepSequenceIncrement = null;
    private String stepSequenceRetrieve = null;

    //~ Methods ////////////////////////////////////////////////////////////////

    public void init(Map props) throws StoreException {
        super.init(props);
        stepSequenceIncrement = (String) props.get("step.sequence.increment");
        stepSequenceRetrieve = (String) props.get("step.sequence.retrieve");
        entrySequenceIncrement = (String) props.get("entry.sequence.increment");
        entrySequenceRetrieve = (String) props.get("entry.sequence.retrieve");
    }

    protected long getNextEntrySequence(Connection c) throws SQLException {
        PreparedStatement stmt = null;
        ResultSet rset = null;

        try {
            stmt = c.prepareStatement(entrySequenceIncrement);
            stmt.executeUpdate();
            rset = stmt.executeQuery(entrySequenceRetrieve);

            rset.next();

            long id = rset.getLong(1);

            return id;
        } finally {
            cleanup(null, stmt, rset);
        }
    }

    protected long getNextStepSequence(Connection c) throws SQLException {
        PreparedStatement stmt = null;
        ResultSet rset = null;

        try {
            stmt = c.prepareStatement(stepSequenceIncrement);
            stmt.executeUpdate();
            rset = stmt.executeQuery(stepSequenceRetrieve);

            rset.next();

            long id = rset.getLong(1);

            return id;
        } finally {
            cleanup(null, stmt, rset);
        }
    }
}

@@ -517,29 +517,31 @@
 ////%0A%0A    pr
-ivate
+otected
  String entr
@@ -565,37 +565,39 @@
 t = null;%0A    pr
-ivate
+otected
  String entrySeq
@@ -616,37 +616,39 @@
 e = null;%0A    pr
-ivate
+otected
  String stepSequ
@@ -679,13 +679,15 @@
   pr
-ivate
+otected
  Str

Fix for WF-396