12
12
import java .sql .CallableStatement ;
13
13
import java .sql .Connection ;
14
14
import java .sql .DriverManager ;
15
- import java .sql .PreparedStatement ;
16
15
import java .sql .ResultSet ;
17
16
import java .sql .SQLException ;
18
17
import java .sql .Statement ;
36
35
@ Tag (Constants .xSQLv11 )
37
36
@ Tag (Constants .xAzureSQLDW )
38
37
public class ResultSetsWithResiliencyTest extends AbstractTest {
39
- static String tableName = AbstractSQLGenerator .escapeIdentifier ("resilencyTestTable" );
38
+ static String tableName = AbstractSQLGenerator .escapeIdentifier (RandomUtil . getIdentifier ( "resiliencyTestTable" ) );
40
39
static int numberOfRows = 10 ;
41
40
42
- private static String callableStatementICROnDoneTestSp = AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatement_ICROnDoneTest_SP" ));
43
- private static String callableStatementICROnDoneErrorTestSp = AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatement_ICROnDoneErrorTest_SP" ));
41
+ private static String callableStatementICROnDoneTestSp = AbstractSQLGenerator
42
+ .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatement_ICROnDoneTest_SP" ));
43
+ private static String callableStatementICROnDoneErrorTestSp = AbstractSQLGenerator
44
+ .escapeIdentifier (RandomUtil .getIdentifier ("CallableStatement_ICROnDoneErrorTest_SP" ));
44
45
private static String createClientCursorInitTableQuery = "create table %s (col1 int, col2 varchar(8000), col3 int identity(1,1))" ;
45
46
private static String createFetchBufferTableQuery = "create table %s (col1 int not null)" ;
46
47
private static String insertIntoFetchBufferTableQuery = "insert into %s (col1) values (%s);" ;
47
- private static final String clientCursorInitTable1 = AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("clientCursorInitTable1" ));
48
- private static final String clientCursorInitTable2 = AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("clientCursorInitTable2" ));
49
- private static final String clientCursorInitTable3 = AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("clientCursorInitTable3" ));
50
- private static final String fetchBufferTestTable1 = AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("fetchBufferTestTable1" ));
51
- private static final String fetchBufferTestTable2 = AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("fetchBufferTestTable2" ));
48
+ private static final String clientCursorInitTable1 = AbstractSQLGenerator
49
+ .escapeIdentifier (RandomUtil .getIdentifier ("clientCursorInitTable1" ));
50
+ private static final String clientCursorInitTable2 = AbstractSQLGenerator
51
+ .escapeIdentifier (RandomUtil .getIdentifier ("clientCursorInitTable2" ));
52
+ private static final String clientCursorInitTable3 = AbstractSQLGenerator
53
+ .escapeIdentifier (RandomUtil .getIdentifier ("clientCursorInitTable3" ));
54
+ private static final String fetchBufferTestTable1 = AbstractSQLGenerator
55
+ .escapeIdentifier (RandomUtil .getIdentifier ("fetchBufferTestTable1" ));
56
+ private static final String fetchBufferTestTable2 = AbstractSQLGenerator
57
+ .escapeIdentifier (RandomUtil .getIdentifier ("fetchBufferTestTable2" ));
52
58
private static final String clientCursorInitTableQuery1 = "select * from " + clientCursorInitTable1 ;
53
59
private static final String clientCursorInitTableQuery2 = "select * from " + clientCursorInitTable2 ;
54
60
private static final String clientCursorInitTableQuery3 = "select * from " + clientCursorInitTable3 ;
@@ -169,18 +175,17 @@ public void testAdaptiveBufferingWithPartiallyBufferedResultSet() throws SQLExce
169
175
public void testResultSetClientCursorInitializerOnDone () throws SQLException {
170
176
try (Connection con = ResiliencyUtils .getConnection (connectionString ); Statement stmt = con .createStatement ()) {
171
177
172
- boolean hasResults = stmt .execute (clientCursorInitTableQuery1 + "; " + clientCursorInitTableQuery2 );
173
- while (hasResults ) {
178
+ boolean hasResults = stmt .execute (clientCursorInitTableQuery1 + "; " + clientCursorInitTableQuery2 );
179
+ while (hasResults ) {
174
180
ResultSet rs = stmt .getResultSet ();
175
181
while (rs .next ()) {}
176
182
hasResults = stmt .getMoreResults ();
177
183
}
178
184
179
185
ResiliencyUtils .killConnection (con , connectionString , 1 );
180
186
181
- try (ResultSet rs = con .createStatement ()
182
- .executeQuery (clientCursorInitTableQuery3 )) {
183
- while (rs .next ()) {}
187
+ try (ResultSet rs = con .createStatement ().executeQuery (clientCursorInitTableQuery3 )) {
188
+ while (rs .next ()) {}
184
189
}
185
190
}
186
191
}
@@ -191,7 +196,7 @@ public void testResultSetErrorClientCursorInitializerOnDone() throws SQLExceptio
191
196
192
197
try {
193
198
boolean hasResults = stmt .execute (clientCursorInitTableQuery1 + "; " + errorQuery );
194
- while (hasResults ) {
199
+ while (hasResults ) {
195
200
ResultSet rs = stmt .getResultSet ();
196
201
while (rs .next ()) {}
197
202
hasResults = stmt .getMoreResults ();
@@ -205,8 +210,7 @@ public void testResultSetErrorClientCursorInitializerOnDone() throws SQLExceptio
205
210
206
211
ResiliencyUtils .killConnection (con , connectionString , 1 );
207
212
208
- try (ResultSet rs = con .createStatement ()
209
- .executeQuery (clientCursorInitTableQuery3 )) {
213
+ try (ResultSet rs = con .createStatement ().executeQuery (clientCursorInitTableQuery3 )) {
210
214
while (rs .next ()) {}
211
215
}
212
216
}
@@ -238,10 +242,8 @@ public void testCallableStatementOnDone() throws SQLException {
238
242
239
243
@ Test
240
244
public void testCallableStatementErrorOnDone () throws SQLException {
241
- String errorCallableStmt = "{CALL "
242
- + callableStatementICROnDoneErrorTestSp + " (?, ?)}" ;
243
- String validCallableStmt = "{CALL "
244
- + callableStatementICROnDoneTestSp + " (?, ?)}" ;
245
+ String errorCallableStmt = "{CALL " + callableStatementICROnDoneErrorTestSp + " (?, ?)}" ;
246
+ String validCallableStmt = "{CALL " + callableStatementICROnDoneTestSp + " (?, ?)}" ;
245
247
246
248
try (Connection con = ResiliencyUtils .getConnection (connectionString )) {
247
249
@@ -286,7 +288,7 @@ public void testResultSetFetchBufferOnDone() throws SQLException {
286
288
287
289
try (Statement stmt = con .createStatement ()) {
288
290
boolean hasResults = stmt .execute (fetchBufferTableQuery1 + "; " + fetchBufferTableQuery2 );
289
- while (hasResults ) {
291
+ while (hasResults ) {
290
292
ResultSet rs = stmt .getResultSet ();
291
293
while (rs .next ()) {}
292
294
hasResults = stmt .getMoreResults ();
@@ -326,7 +328,7 @@ public void testResultSetErrorFetchBufferOnDone() throws SQLException {
326
328
327
329
try (Statement stmt = con .createStatement ()) {
328
330
boolean hasResults = stmt .execute (fetchBufferTableQuery1 + "; " + errorQuery );
329
- while (hasResults ) {
331
+ while (hasResults ) {
330
332
ResultSet rs = stmt .getResultSet ();
331
333
while (rs .next ()) {}
332
334
hasResults = stmt .getMoreResults ();
@@ -386,7 +388,7 @@ public void testMultipleResultSets() throws Exception {
386
388
@ Test
387
389
public void testResultSetWithException () throws Exception {
388
390
try (Connection c = ResiliencyUtils .getConnection (connectionString ); Statement s = c .createStatement ();
389
- ResultSet rs = s .executeQuery ("SELECT 1/0" )) {
391
+ ResultSet rs = s .executeQuery ("SELECT 1/0" )) {
390
392
391
393
while (rs .next ()) {
392
394
ResiliencyUtils .killConnection (c , connectionString , 0 );
0 commit comments