KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > spi > jdbc > MySQLWorkflowStore


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow.spi.jdbc;
6
7 import com.opensymphony.workflow.StoreException;
8
9 import java.sql.Connection JavaDoc;
10 import java.sql.PreparedStatement JavaDoc;
11 import java.sql.ResultSet JavaDoc;
12 import java.sql.SQLException JavaDoc;
13
14 import java.util.Map JavaDoc;
15
16
17 /**
18  * @author Christopher Farnham
19  * Created on Feb 27, 2004
20  */

21 public class MySQLWorkflowStore extends JDBCWorkflowStore {
22     //~ Instance fields ////////////////////////////////////////////////////////
23

24     private String JavaDoc _stepSequenceIncrement = null;
25     private String JavaDoc _stepSequenceRetrieve = null;
26
27     //~ Methods ////////////////////////////////////////////////////////////////
28

29     public void init(Map JavaDoc props) throws StoreException {
30         super.init(props);
31         _stepSequenceIncrement = (String JavaDoc) props.get("step.sequence.increment");
32         _stepSequenceRetrieve = (String JavaDoc) props.get("step.sequence.retrieve");
33     }
34
35     protected long getNextStepSequence(Connection JavaDoc c) throws SQLException JavaDoc {
36         PreparedStatement JavaDoc stmt = null;
37         ResultSet JavaDoc rset = null;
38
39         try {
40             stmt = c.prepareStatement(_stepSequenceIncrement);
41             stmt.executeUpdate();
42             rset = stmt.executeQuery(_stepSequenceRetrieve);
43
44             rset.next();
45
46             long id = rset.getLong(1);
47
48             return id;
49         } finally {
50             cleanup(null, stmt, rset);
51         }
52     }
53 }
54
Popular Tags