21
21
import io .shardingsphere .core .executor .BaseStatementUnit ;
22
22
import io .shardingsphere .core .executor .ExecuteCallback ;
23
23
import io .shardingsphere .core .executor .ExecutorEngine ;
24
+ import io .shardingsphere .core .executor .threadlocal .ExecutorDataMap ;
25
+ import io .shardingsphere .core .executor .threadlocal .ExecutorExceptionHandler ;
24
26
import lombok .RequiredArgsConstructor ;
25
27
26
28
import java .sql .PreparedStatement ;
27
29
import java .sql .ResultSet ;
28
30
import java .sql .SQLException ;
29
31
import java .util .Collection ;
30
32
import java .util .List ;
33
+ import java .util .Map ;
31
34
32
35
/**
33
36
* PreparedStatement Executor for multiple threads.
@@ -52,6 +55,8 @@ public final class PreparedStatementExecutor {
52
55
* @throws SQLException SQL exception
53
56
*/
54
57
public List <ResultSet > executeQuery () throws SQLException {
58
+ final boolean isExceptionThrown = ExecutorExceptionHandler .isExceptionThrown ();
59
+ final Map <String , Object > dataMap = ExecutorDataMap .getDataMap ();
55
60
return executorEngine .execute (preparedStatementUnits , new ExecuteCallback <ResultSet >() {
56
61
57
62
@ Override
@@ -63,6 +68,16 @@ public ResultSet execute(final BaseStatementUnit baseStatementUnit) throws Excep
63
68
public SQLType getSQLType () {
64
69
return sqlType ;
65
70
}
71
+
72
+ @ Override
73
+ public boolean isExceptionThrown () {
74
+ return isExceptionThrown ;
75
+ }
76
+
77
+ @ Override
78
+ public Map <String , Object > getDataMap () {
79
+ return dataMap ;
80
+ }
66
81
});
67
82
}
68
83
@@ -73,6 +88,8 @@ public SQLType getSQLType() {
73
88
* @throws SQLException SQL exception
74
89
*/
75
90
public int executeUpdate () throws SQLException {
91
+ final boolean isExceptionThrown = ExecutorExceptionHandler .isExceptionThrown ();
92
+ final Map <String , Object > dataMap = ExecutorDataMap .getDataMap ();
76
93
List <Integer > results = executorEngine .execute (preparedStatementUnits , new ExecuteCallback <Integer >() {
77
94
78
95
@ Override
@@ -84,6 +101,16 @@ public Integer execute(final BaseStatementUnit baseStatementUnit) throws Excepti
84
101
public SQLType getSQLType () {
85
102
return sqlType ;
86
103
}
104
+
105
+ @ Override
106
+ public boolean isExceptionThrown () {
107
+ return isExceptionThrown ;
108
+ }
109
+
110
+ @ Override
111
+ public Map <String , Object > getDataMap () {
112
+ return dataMap ;
113
+ }
87
114
});
88
115
return accumulate (results );
89
116
}
@@ -103,6 +130,8 @@ private int accumulate(final List<Integer> results) {
103
130
* @throws SQLException SQL exception
104
131
*/
105
132
public boolean execute () throws SQLException {
133
+ final boolean isExceptionThrown = ExecutorExceptionHandler .isExceptionThrown ();
134
+ final Map <String , Object > dataMap = ExecutorDataMap .getDataMap ();
106
135
List <Boolean > result = executorEngine .execute (preparedStatementUnits , new ExecuteCallback <Boolean >() {
107
136
108
137
@ Override
@@ -114,6 +143,16 @@ public Boolean execute(final BaseStatementUnit baseStatementUnit) throws Excepti
114
143
public SQLType getSQLType () {
115
144
return sqlType ;
116
145
}
146
+
147
+ @ Override
148
+ public boolean isExceptionThrown () {
149
+ return isExceptionThrown ;
150
+ }
151
+
152
+ @ Override
153
+ public Map <String , Object > getDataMap () {
154
+ return dataMap ;
155
+ }
117
156
});
118
157
if (null == result || result .isEmpty () || null == result .get (0 )) {
119
158
return false ;
0 commit comments