/[projects]/miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/invocations/SQLQueryInvocation.java
ViewVC logotype

Contents of /miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/invocations/SQLQueryInvocation.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3212 - (show annotations) (download)
Thu Dec 28 09:34:47 2017 UTC (6 years, 4 months ago) by torben
File size: 794 byte(s)
Use generics to encapsulate returned value
1 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<ResultSet> {
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 }

  ViewVC Help
Powered by ViewVC 1.1.20