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

Annotation of /miscJava/CircuitBreaker/src/main/java/dk/thoerup/circuitbreaker/invocations/SQLUpdateInvocation.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3212 - (hide annotations) (download)
Thu Dec 28 09:34:47 2017 UTC (6 years, 5 months ago) by torben
File size: 766 byte(s)
Use generics to encapsulate returned value
1 torben 472 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 torben 3212 public class SQLUpdateInvocation implements CircuitInvocation<Integer> {
9 torben 472
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     }

  ViewVC Help
Powered by ViewVC 1.1.20