1 |
package dk.thoerup.circuitbreaker.invocations;
|
2 |
|
3 |
import java.sql.PreparedStatement;
|
4 |
import java.sql.Statement;
|
5 |
|
6 |
import dk.thoerup.circuitbreaker.CircuitInvocation;
|
7 |
|
8 |
public class SQLUpdateInvocation implements CircuitInvocation {
|
9 |
|
10 |
PreparedStatement pStatement = null;
|
11 |
Statement statement = null;
|
12 |
String sql = null;
|
13 |
|
14 |
|
15 |
public SQLUpdateInvocation(Statement stmt, String sql) {
|
16 |
this.statement = stmt;
|
17 |
this.sql = sql;
|
18 |
}
|
19 |
|
20 |
public SQLUpdateInvocation(PreparedStatement pstmt) {
|
21 |
pStatement = pstmt;
|
22 |
}
|
23 |
|
24 |
|
25 |
public Integer proceed() throws Exception {
|
26 |
int rows;
|
27 |
|
28 |
if (pStatement != null) {
|
29 |
rows = pStatement.executeUpdate();
|
30 |
} else {
|
31 |
rows = statement.executeUpdate(sql);
|
32 |
}
|
33 |
|
34 |
return rows;
|
35 |
}
|
36 |
|
37 |
|
38 |
}
|