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