36
36
import static org .testng .Assert .fail ;
37
37
38
38
39
- @ Test (groups = { "integration" })
39
+ @ Test (groups = {"integration" })
40
40
public class StatementTest extends JdbcIntegrationTest {
41
41
private static final Logger log = LoggerFactory .getLogger (StatementTest .class );
42
42
43
- @ Test (groups = { "integration" })
43
+ @ Test (groups = {"integration" })
44
44
public void testExecuteQuerySimpleNumbers () throws Exception {
45
45
try (Connection conn = getJdbcConnection ()) {
46
46
try (Statement stmt = conn .createStatement ()) {
@@ -59,12 +59,12 @@ public void testExecuteQuerySimpleNumbers() throws Exception {
59
59
assertEquals (rs .getLong ("num" ), 1 );
60
60
assertFalse (rs .next ());
61
61
}
62
- Assert .assertFalse (((StatementImpl )stmt ).getLastQueryId ().isEmpty ());
62
+ Assert .assertFalse (((StatementImpl ) stmt ).getLastQueryId ().isEmpty ());
63
63
}
64
64
}
65
65
}
66
66
67
- @ Test (groups = { "integration" })
67
+ @ Test (groups = {"integration" })
68
68
public void testExecuteQuerySimpleFloats () throws Exception {
69
69
try (Connection conn = getJdbcConnection ()) {
70
70
try (Statement stmt = conn .createStatement ()) {
@@ -80,7 +80,7 @@ public void testExecuteQuerySimpleFloats() throws Exception {
80
80
}
81
81
}
82
82
83
- @ Test (groups = { "integration" })
83
+ @ Test (groups = {"integration" })
84
84
public void testExecuteQueryBooleans () throws Exception {
85
85
try (Connection conn = getJdbcConnection ()) {
86
86
try (Statement stmt = conn .createStatement ()) {
@@ -94,7 +94,7 @@ public void testExecuteQueryBooleans() throws Exception {
94
94
}
95
95
}
96
96
97
- @ Test (groups = { "integration" })
97
+ @ Test (groups = {"integration" })
98
98
public void testExecuteQueryStrings () throws Exception {
99
99
try (Connection conn = getJdbcConnection ()) {
100
100
try (Statement stmt = conn .createStatement ()) {
@@ -108,7 +108,7 @@ public void testExecuteQueryStrings() throws Exception {
108
108
}
109
109
}
110
110
111
- @ Test (groups = { "integration" })
111
+ @ Test (groups = {"integration" })
112
112
public void testExecuteQueryNulls () throws Exception {
113
113
try (Connection conn = getJdbcConnection ()) {
114
114
try (Statement stmt = conn .createStatement ()) {
@@ -124,7 +124,7 @@ public void testExecuteQueryNulls() throws Exception {
124
124
}
125
125
}
126
126
127
- @ Test (groups = { "integration" })
127
+ @ Test (groups = {"integration" })
128
128
public void testExecuteQueryDates () throws Exception {
129
129
try (Connection conn = getJdbcConnection ()) {
130
130
try (Statement stmt = conn .createStatement ()) {
@@ -144,7 +144,7 @@ public void testExecuteQueryDates() throws Exception {
144
144
}
145
145
}
146
146
147
- @ Test (groups = { "integration" })
147
+ @ Test (groups = {"integration" })
148
148
public void testExecuteUpdateSimpleNumbers () throws Exception {
149
149
try (Connection conn = getJdbcConnection ()) {
150
150
try (Statement stmt = conn .createStatement ()) {
@@ -163,7 +163,7 @@ public void testExecuteUpdateSimpleNumbers() throws Exception {
163
163
}
164
164
}
165
165
166
- @ Test (groups = { "integration" })
166
+ @ Test (groups = {"integration" })
167
167
public void testExecuteUpdateSimpleFloats () throws Exception {
168
168
try (Connection conn = getJdbcConnection ()) {
169
169
try (Statement stmt = conn .createStatement ()) {
@@ -183,7 +183,7 @@ public void testExecuteUpdateSimpleFloats() throws Exception {
183
183
}
184
184
}
185
185
186
- @ Test (groups = { "integration" })
186
+ @ Test (groups = {"integration" })
187
187
public void testExecuteUpdateBooleans () throws Exception {
188
188
try (Connection conn = getJdbcConnection ()) {
189
189
try (Statement stmt = conn .createStatement ()) {
@@ -202,7 +202,7 @@ public void testExecuteUpdateBooleans() throws Exception {
202
202
}
203
203
}
204
204
205
- @ Test (groups = { "integration" })
205
+ @ Test (groups = {"integration" })
206
206
public void testExecuteUpdateStrings () throws Exception {
207
207
try (Connection conn = getJdbcConnection ()) {
208
208
try (Statement stmt = conn .createStatement ()) {
@@ -221,7 +221,7 @@ public void testExecuteUpdateStrings() throws Exception {
221
221
}
222
222
}
223
223
224
- @ Test (groups = { "integration" })
224
+ @ Test (groups = {"integration" })
225
225
public void testExecuteUpdateNulls () throws Exception {
226
226
try (Connection conn = getJdbcConnection ()) {
227
227
try (Statement stmt = conn .createStatement ()) {
@@ -240,7 +240,7 @@ public void testExecuteUpdateNulls() throws Exception {
240
240
}
241
241
}
242
242
243
- @ Test (groups = { "integration" })
243
+ @ Test (groups = {"integration" })
244
244
public void testExecuteUpdateDates () throws Exception {
245
245
try (Connection conn = getJdbcConnection ()) {
246
246
try (Statement stmt = conn .createStatement ()) {
@@ -263,7 +263,7 @@ public void testExecuteUpdateDates() throws Exception {
263
263
}
264
264
265
265
266
- @ Test (groups = { "integration" })
266
+ @ Test (groups = {"integration" })
267
267
public void testExecuteUpdateBatch () throws Exception {
268
268
try (Connection conn = getJdbcConnection ()) {
269
269
try (Statement stmt = conn .createStatement ()) {
@@ -291,7 +291,7 @@ public void testExecuteUpdateBatch() throws Exception {
291
291
}
292
292
}
293
293
294
- @ Test (groups = { "integration" })
294
+ @ Test (groups = {"integration" })
295
295
public void testJdbcEscapeSyntax () throws Exception {
296
296
if (ClickHouseVersion .of (getServerVersion ()).check ("(,23.8]" )) {
297
297
return ; // there is no `timestamp` function TODO: fix in JDBC
@@ -344,7 +344,7 @@ public void testJdbcEscapeSyntax() throws Exception {
344
344
}
345
345
}
346
346
347
- @ Test (groups = { "integration" })
347
+ @ Test (groups = {"integration" })
348
348
public void testExecuteQueryTimeout () throws Exception {
349
349
try (Connection conn = getJdbcConnection ()) {
350
350
try (Statement stmt = conn .createStatement ()) {
@@ -359,7 +359,7 @@ public void testExecuteQueryTimeout() throws Exception {
359
359
}
360
360
361
361
362
- @ Test (groups = { "integration" })
362
+ @ Test (groups = {"integration" })
363
363
public void testSettingRole () throws SQLException {
364
364
if (earlierThan (24 , 4 )) {//Min version is 24.4
365
365
return ;
@@ -445,15 +445,15 @@ public void testGettingArrays() throws Exception {
445
445
Array numberArray = rs .getArray ("number_array" );
446
446
assertEquals (((Object []) numberArray .getArray ()).length , 3 );
447
447
System .out .println (((Object []) numberArray .getArray ())[0 ].getClass ().getName ());
448
- assertEquals (numberArray .getArray (), new short [] {1 , 2 , 3 } );
448
+ assertEquals (numberArray .getArray (), new short []{1 , 2 , 3 });
449
449
Array stringArray = rs .getArray ("str_array" );
450
450
assertEquals (((Object []) stringArray .getArray ()).length , 3 );
451
451
assertEquals (Arrays .stream (((Object []) stringArray .getArray ())).toList (), Arrays .asList ("val1" , "val2" , "val3" ));
452
452
}
453
453
}
454
454
455
455
456
- @ Test (groups = { "integration" })
456
+ @ Test (groups = {"integration" })
457
457
public void testWithIPs () throws Exception {
458
458
try (Connection conn = getJdbcConnection ()) {
459
459
try (Statement stmt = conn .createStatement ()) {
@@ -481,14 +481,14 @@ public void testConnectionExhaustion() throws Exception {
481
481
482
482
try (Connection conn = getJdbcConnection (properties )) {
483
483
try (Statement stmt = conn .createStatement ()) {
484
- for (int i = 0 ; i < maxNumConnections * 2 ; i ++) {
484
+ for (int i = 0 ; i < maxNumConnections * 2 ; i ++) {
485
485
stmt .executeQuery ("SELECT number FROM system.numbers LIMIT 100" );
486
486
}
487
487
}
488
488
}
489
489
}
490
490
491
- @ Test (groups = { "integration" })
491
+ @ Test (groups = {"integration" })
492
492
public void testConcurrentCancel () throws Exception {
493
493
int maxNumConnections = 3 ;
494
494
Properties p = new Properties ();
@@ -524,7 +524,7 @@ public void testConcurrentCancel() throws Exception {
524
524
public void testTextFormatInResponse () throws Exception {
525
525
try (Connection conn = getJdbcConnection ();
526
526
Statement stmt = conn .createStatement ()) {
527
- Assert .expectThrows (SQLException .class , () ->stmt .executeQuery ("SELECT 1 FORMAT JSON" ));
527
+ Assert .expectThrows (SQLException .class , () -> stmt .executeQuery ("SELECT 1 FORMAT JSON" ));
528
528
}
529
529
}
530
530
@@ -543,7 +543,7 @@ void testWithClause() throws Exception {
543
543
assertEquals (count , 100 );
544
544
}
545
545
546
- @ Test (groups = { "integration" })
546
+ @ Test (groups = {"integration" })
547
547
public void testSwitchDatabase () throws Exception {
548
548
String databaseName = getDatabase () + "_test_switch" ;
549
549
String createSql = "CREATE TABLE switchDatabaseWithUse (id UInt8, words String) ENGINE = MergeTree ORDER BY ()" ;
@@ -571,7 +571,7 @@ public void testSwitchDatabase() throws Exception {
571
571
}
572
572
573
573
574
- @ Test (groups = { "integration" })
574
+ @ Test (groups = {"integration" })
575
575
public void testNewLineSQLParsing () throws Exception {
576
576
try (Connection conn = getJdbcConnection ()) {
577
577
String sqlCreate = "CREATE TABLE balance ( `id` UUID, `currency` String, `amount` Decimal(64, 18), `create_time` DateTime64(6), `_version` UInt64, `_sign` UInt8 ) ENGINE = ReplacingMergeTree PRIMARY KEY id ORDER BY id;" ;
@@ -636,20 +636,20 @@ public void testNewLineSQLParsing() throws Exception {
636
636
}
637
637
638
638
639
- @ Test (groups = { "integration" })
639
+ @ Test (groups = {"integration" })
640
640
public void testNullableFixedStringType () throws Exception {
641
641
try (Connection conn = getJdbcConnection ()) {
642
642
String sqlCreate = "CREATE TABLE `data_types` (`f1` FixedString(4),`f2` LowCardinality(FixedString(4)), `f3` Nullable(FixedString(4)), `f4` LowCardinality(Nullable(FixedString(4))) ) ENGINE Memory;" ;
643
643
try (Statement stmt = conn .createStatement ()) {
644
644
int r = stmt .executeUpdate (sqlCreate );
645
645
assertEquals (r , 0 );
646
646
}
647
- try (Statement stmt = conn .createStatement ()) {
647
+ try (Statement stmt = conn .createStatement ()) {
648
648
String sqlInsert = "INSERT INTO `data_types` VALUES ('val1', 'val2', 'val3', 'val4')" ;
649
649
int r = stmt .executeUpdate (sqlInsert );
650
650
assertEquals (r , 1 );
651
651
}
652
- try (Statement stmt = conn .createStatement ()) {
652
+ try (Statement stmt = conn .createStatement ()) {
653
653
String sqlSelect = "SELECT * FROM `data_types`" ;
654
654
ResultSet rs = stmt .executeQuery (sqlSelect );
655
655
assertTrue (rs .next ());
@@ -659,7 +659,7 @@ public void testNullableFixedStringType() throws Exception {
659
659
assertEquals (rs .getString (4 ), "val4" );
660
660
assertFalse (rs .next ());
661
661
}
662
- try (Statement stmt = conn .createStatement ()) {
662
+ try (Statement stmt = conn .createStatement ()) {
663
663
String sqlSelect = "SELECT f4 FROM `data_types`" ;
664
664
ResultSet rs = stmt .executeQuery (sqlSelect );
665
665
assertTrue (rs .next ());
@@ -668,7 +668,7 @@ public void testNullableFixedStringType() throws Exception {
668
668
}
669
669
}
670
670
671
- @ Test (groups = { "integration" })
671
+ @ Test (groups = {"integration" })
672
672
public void testWasNullFlagArray () throws Exception {
673
673
try (Connection conn = getJdbcConnection ()) {
674
674
String sql = "SELECT NULL, ['value1', 'value2']" ;
@@ -707,7 +707,7 @@ public void testWasNullFlagArray() throws Exception {
707
707
}
708
708
}
709
709
710
- @ Test (groups = { "integration" })
710
+ @ Test (groups = {"integration" })
711
711
public void testExecuteWithMaxRows () throws Exception {
712
712
try (Connection conn = getJdbcConnection ()) {
713
713
try (Statement stmt = conn .createStatement ()) {
@@ -734,7 +734,7 @@ public void testExecuteWithMaxRows() throws Exception {
734
734
ServerSettings .RESULT_OVERFLOW_MODE_THROW );
735
735
props .setProperty (ClientConfigProperties .serverSetting (ServerSettings .MAX_RESULT_ROWS ), "100" );
736
736
try (Connection conn = getJdbcConnection (props );
737
- Statement stmt = conn .createStatement ()) {
737
+ Statement stmt = conn .createStatement ()) {
738
738
739
739
Assert .assertThrows (SQLException .class , () -> stmt .execute ("SELECT * FROM generate_series(0, 100000)" ));
740
740
@@ -770,7 +770,7 @@ public void testDDLStatements() throws Exception {
770
770
return ; // skip because we do not want to create extra on cloud instance
771
771
}
772
772
try (Connection conn = getJdbcConnection ()) {
773
- try (Statement stmt = conn .createStatement ()){
773
+ try (Statement stmt = conn .createStatement ()) {
774
774
Assert .assertFalse (stmt .execute ("CREATE USER IF NOT EXISTS 'user011' IDENTIFIED BY 'password'" ));
775
775
776
776
try (ResultSet rs = stmt .executeQuery ("SHOW USERS" )) {
@@ -804,14 +804,14 @@ public void testEnquoteIdentifier() throws Exception {
804
804
try (Connection conn = getJdbcConnection (); Statement stmt = conn .createStatement ()) {
805
805
Object [][] identifiers = {{"simple_identifier" , false }, {"complex identified" , true }};
806
806
for (Object [] aCase : identifiers ) {
807
- stmt .enquoteIdentifier ((String )aCase [0 ], (boolean ) aCase [1 ]);
807
+ stmt .enquoteIdentifier ((String ) aCase [0 ], (boolean ) aCase [1 ]);
808
808
}
809
809
}
810
810
}
811
811
812
812
@ DataProvider (name = "ncharLiteralTestData" )
813
813
public Object [][] ncharLiteralTestData () {
814
- return new Object [][] {
814
+ return new Object [][]{
815
815
// input, expected output
816
816
{"test" , "N'test'" },
817
817
{"O'Reilly" , "N'O''Reilly'" },
@@ -839,7 +839,7 @@ public void testEnquoteNCharLiteral_NullInput() throws SQLException {
839
839
840
840
@ Test (groups = {"integration" })
841
841
public void testIsSimpleIdentifier () throws Exception {
842
- Object [][] identifiers = new Object [][] {
842
+ Object [][] identifiers = new Object [][]{
843
843
// identifier, expected result
844
844
{"Hello" , true },
845
845
{"hello_world" , true },
@@ -928,7 +928,7 @@ public void testCloseOnCompletion() throws Exception {
928
928
try (Statement stmt = conn .createStatement ()) {
929
929
stmt .closeOnCompletion ();
930
930
try (ResultSet rs = stmt .executeQuery ("CREATE TABLE test_empty_table (id String) Engine Memory" )) {
931
- }catch (Exception ex ){
931
+ } catch (Exception ex ) {
932
932
ex .printStackTrace ();
933
933
}
934
934
0 commit comments